summaryrefslogtreecommitdiffstats
path: root/test/PCH
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2013-06-10 20:45:12 +0000
committerdim <dim@FreeBSD.org>2013-06-10 20:45:12 +0000
commitea266cad53e3d49771fa38103913d3ec7a166694 (patch)
tree8f7776b7310bebaf415ac5b69e46e9f928c37144 /test/PCH
parentc72c57c9e9b69944e3e009cd5e209634839581d3 (diff)
downloadFreeBSD-src-ea266cad53e3d49771fa38103913d3ec7a166694.zip
FreeBSD-src-ea266cad53e3d49771fa38103913d3ec7a166694.tar.gz
Vendor import of clang tags/RELEASE_33/final r183502 (effectively, 3.3
release): http://llvm.org/svn/llvm-project/cfe/tags/RELEASE_33/final@183502
Diffstat (limited to 'test/PCH')
-rw-r--r--test/PCH/captured-stmt.cpp42
-rw-r--r--test/PCH/cxx-typeid.cpp6
-rw-r--r--test/PCH/cxx-typeid.h43
-rw-r--r--test/PCH/cxx-using.cpp7
-rw-r--r--test/PCH/cxx11-statement-attributes.cpp3
-rw-r--r--test/PCH/cxx1y-decltype-auto.cpp24
-rw-r--r--test/PCH/cxx1y-default-initializer.cpp30
-rw-r--r--test/PCH/functions.c6
-rw-r--r--test/PCH/headersearch.cpp6
-rw-r--r--test/PCH/method_pool.m12
-rw-r--r--test/PCH/nonvisible-external-defs.c2
-rw-r--r--test/PCH/reloc.c4
-rw-r--r--test/PCH/tentative-defs.c3
-rw-r--r--test/PCH/thread-local.cpp20
-rw-r--r--test/PCH/typo.cpp19
-rw-r--r--test/PCH/typo.m3
16 files changed, 188 insertions, 42 deletions
diff --git a/test/PCH/captured-stmt.cpp b/test/PCH/captured-stmt.cpp
new file mode 100644
index 0000000..6f5ca38
--- /dev/null
+++ b/test/PCH/captured-stmt.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -x c++-header -emit-pch %s -o %t
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER_INCLUDED
+#define HEADER_INCLUDED
+
+static inline void foo(int &x, int y) {
+ // Capturing x and y
+ #pragma clang __debug captured
+ {
+ x += y;
+ }
+}
+
+struct C {
+ int val;
+
+ explicit C(int v) : val(v) { }
+
+ void bar(int &x) {
+ // Capturing x and this
+ #pragma clang __debug captured
+ {
+ x += val;
+ }
+ }
+};
+
+#else
+
+void test_foo(int &x) {
+ foo(x, 10);
+}
+
+void test_bar(int &x) {
+ C Obj(10);
+ Obj.bar(x);
+}
+
+#endif
diff --git a/test/PCH/cxx-typeid.cpp b/test/PCH/cxx-typeid.cpp
index d1e0f9d..534863a 100644
--- a/test/PCH/cxx-typeid.cpp
+++ b/test/PCH/cxx-typeid.cpp
@@ -1,8 +1,8 @@
// Test this without pch.
-// RUN: %clang -include %S/cxx-typeid.h -fsyntax-only -Xclang -verify %s
+// RUN: %clang_cc1 -include %S/cxx-typeid.h -fsyntax-only -verify %s
-// RUN: %clang -ccc-pch-is-pch -x c++-header -o %t.gch %S/cxx-typeid.h
-// RUN: %clang -ccc-pch-is-pch -include %t -fsyntax-only -Xclang -verify %s
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t.pch %S/cxx-typeid.h
+// RUN: %clang_cc1 -include-pch %t.pch -fsyntax-only -verify %s
// expected-no-diagnostics
diff --git a/test/PCH/cxx-typeid.h b/test/PCH/cxx-typeid.h
index aa3b16a..f10f4de 100644
--- a/test/PCH/cxx-typeid.h
+++ b/test/PCH/cxx-typeid.h
@@ -1,3 +1,44 @@
// Header for PCH test cxx-typeid.cpp
-#include <typeinfo>
+#ifndef CXX_TYPEID_H
+#define CXX_TYPEID_H
+
+namespace std {
+
+class type_info
+{
+public:
+ virtual ~type_info();
+
+ bool operator==(const type_info& rhs) const;
+ bool operator!=(const type_info& rhs) const;
+
+ bool before(const type_info& rhs) const;
+ unsigned long hash_code() const;
+ const char* name() const;
+
+ type_info(const type_info& rhs);
+ type_info& operator=(const type_info& rhs);
+};
+
+class bad_cast
+{
+public:
+ bad_cast();
+ bad_cast(const bad_cast&);
+ bad_cast& operator=(const bad_cast&);
+ virtual const char* what() const;
+};
+
+class bad_typeid
+{
+public:
+ bad_typeid();
+ bad_typeid(const bad_typeid&);
+ bad_typeid& operator=(const bad_typeid&);
+ virtual const char* what() const;
+};
+
+} // std
+
+#endif
diff --git a/test/PCH/cxx-using.cpp b/test/PCH/cxx-using.cpp
index 2ca7dad..2cab1f0 100644
--- a/test/PCH/cxx-using.cpp
+++ b/test/PCH/cxx-using.cpp
@@ -6,10 +6,9 @@
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
void m() {
- D s; // expected-note {{candidate function}}
+ D s;
s.f(); // expected-error {{no matching member}}
}
-
-
-// expected-note {{candidate function}}
+// expected-note@cxx-using.h:9 {{candidate function}}
+// expected-note@cxx-using.h:15 {{candidate function}}
diff --git a/test/PCH/cxx11-statement-attributes.cpp b/test/PCH/cxx11-statement-attributes.cpp
index 3bb7b40..722ca6e 100644
--- a/test/PCH/cxx11-statement-attributes.cpp
+++ b/test/PCH/cxx11-statement-attributes.cpp
@@ -4,8 +4,7 @@
// RUN: %clang_cc1 -x c++-header -emit-pch -std=c++11 -o %t %S/Inputs/cxx11-statement-attributes.h
// RUN: %clang_cc1 -include-pch %t -std=c++11 -Wimplicit-fallthrough -fsyntax-only %s -o - -verify
-// Warning from Inputs/cxx11-statement-attributes.h:
-// expected-warning@10 {{fallthrough annotation does not directly precede switch label}}
+// expected-warning@Inputs/cxx11-statement-attributes.h:10 {{fallthrough annotation does not directly precede switch label}}
void g(int n) {
f<1>(n); // expected-note {{in instantiation of function template specialization 'f<1>' requested here}}
diff --git a/test/PCH/cxx1y-decltype-auto.cpp b/test/PCH/cxx1y-decltype-auto.cpp
new file mode 100644
index 0000000..a1c9339
--- /dev/null
+++ b/test/PCH/cxx1y-decltype-auto.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+template<typename T> void f(T t) {
+ auto a = t.x;
+ decltype(auto) b = t.x;
+ auto c = (t.x);
+ decltype(auto) d = (t.x);
+}
+
+#else
+
+struct Z {
+ int x : 5; // expected-note {{bit-field}}
+};
+
+// expected-error@12 {{non-const reference cannot bind to bit-field 'x'}}
+template void f(Z); // expected-note {{in instantiation of}}
+
+#endif
diff --git a/test/PCH/cxx1y-default-initializer.cpp b/test/PCH/cxx1y-default-initializer.cpp
new file mode 100644
index 0000000..5a68f27
--- /dev/null
+++ b/test/PCH/cxx1y-default-initializer.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+
+struct A {
+ int x;
+ int y = 3;
+ int z = x + y;
+};
+template<typename T> constexpr A make() { return A {}; }
+template<typename T> constexpr A make(T t) { return A { t }; }
+
+struct B {
+ int z1, z2 = z1;
+ constexpr B(int k) : z1(k) {}
+};
+
+#else
+
+static_assert(A{}.z == 3, "");
+static_assert(A{1}.z == 4, "");
+static_assert(A{.y = 5}.z == 5, ""); // expected-warning {{C99}}
+static_assert(A{3, .y = 1}.z == 4, ""); // expected-warning {{C99}}
+static_assert(make<int>().z == 3, "");
+static_assert(make<int>(12).z == 15, "");
+
+#endif
diff --git a/test/PCH/functions.c b/test/PCH/functions.c
index 35e3921..fa2ba8d 100644
--- a/test/PCH/functions.c
+++ b/test/PCH/functions.c
@@ -4,18 +4,20 @@
// Test with pch.
// RUN: %clang_cc1 -emit-pch -o %t %S/functions.h
// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
-// expected-note{{'f1' declared here}}
+
int f0(int x0, int y0, ...) { return x0 + y0; }
-// expected-note{{passing argument to parameter here}}
+
float *test_f1(int val, double x, double y) {
if (val > 5)
return f1(x, y);
else
return f1(x); // expected-error{{too few arguments to function call}}
+ // expected-note@functions.h:7{{'f1' declared here}}
}
void test_g0(int *x, float * y) {
g0(y); // expected-warning{{incompatible pointer types passing 'float *' to parameter of type 'int *'}}
+ // expected-note@functions.h:9{{passing argument to parameter here}}
g0(x);
}
diff --git a/test/PCH/headersearch.cpp b/test/PCH/headersearch.cpp
index 8ca0c36..4b24ac6 100644
--- a/test/PCH/headersearch.cpp
+++ b/test/PCH/headersearch.cpp
@@ -20,15 +20,15 @@
// RUN: cp -pR %t_orig %t_moved
// Check diagnostic with location in original source:
-// RUN: %clang_cc1 -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -Wpadded -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: %clang_cc1 -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -Wpadded -emit-llvm-only %s 2> %t.stderr
// RUN: grep 'struct orig_sub' %t.stderr
// Check diagnostic with 2nd location in original source:
-// RUN: not %clang_cc1 -DREDECL -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: not %clang_cc1 -DREDECL -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-llvm-only %s 2> %t.stderr
// RUN: grep 'void foo' %t.stderr
// Check diagnostic with instantiation location in original source:
-// RUN: not %clang_cc1 -DINSTANTIATION -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-obj -o %t.o %s 2> %t.stderr
+// RUN: not %clang_cc1 -DINSTANTIATION -include-pch all.h.pch -I%t_moved -I%t_moved/sub2 -emit-llvm-only %s 2> %t.stderr
// RUN: grep 'orig_sub2_1' %t.stderr
void qq(orig_sub*) {all();}
diff --git a/test/PCH/method_pool.m b/test/PCH/method_pool.m
index 20010fb..139f8ba 100644
--- a/test/PCH/method_pool.m
+++ b/test/PCH/method_pool.m
@@ -9,13 +9,5 @@ int message_id(id x) {
return [x instMethod:17]; // expected-warning{{multiple methods}}
}
-
-
-
-
-/* Whitespace below is significant */
-/* expected-note{{using}} */
-
-
-
-/* expected-note{{also}} */
+/* expected-note@method_pool.h:17{{using}} */
+/* expected-note@method_pool.h:21{{also}} */
diff --git a/test/PCH/nonvisible-external-defs.c b/test/PCH/nonvisible-external-defs.c
index 49392ca..092e2c9 100644
--- a/test/PCH/nonvisible-external-defs.c
+++ b/test/PCH/nonvisible-external-defs.c
@@ -7,4 +7,4 @@
int g(int, float); // expected-error{{conflicting types}}
-// expected-note{{previous declaration}}
+// expected-note@nonvisible-external-defs.h:10{{previous declaration}}
diff --git a/test/PCH/reloc.c b/test/PCH/reloc.c
index 4c426e4..8dabb8b 100644
--- a/test/PCH/reloc.c
+++ b/test/PCH/reloc.c
@@ -10,5 +10,5 @@ int x = 2; // expected-error{{redefinition}}
int y = 5; // expected-error{{redefinition}}
-// expected-note{{previous definition}}
-// expected-note{{previous definition}}
+// expected-note@libroot/usr/include/reloc.h:13{{previous definition}}
+// expected-note@libroot/usr/include/reloc2.h:14{{previous definition}}
diff --git a/test/PCH/tentative-defs.c b/test/PCH/tentative-defs.c
index 0072818..4288230 100644
--- a/test/PCH/tentative-defs.c
+++ b/test/PCH/tentative-defs.c
@@ -5,5 +5,4 @@
// RUN: grep "@variable = common global i32 0" %t | count 1
// RUN: grep "@incomplete_array = common global .*1 x i32" %t | count 1
-
-// FIXME: tentative-defs.h expected-warning{{tentative}}
+// FIXME: expected-warning@tentative-defs.h:9{{tentative}}
diff --git a/test/PCH/thread-local.cpp b/test/PCH/thread-local.cpp
new file mode 100644
index 0000000..f65c12a
--- /dev/null
+++ b/test/PCH/thread-local.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -triple x86_64-linux-gnu -emit-pch %s -o %t
+// RUN: %clang_cc1 -pedantic-errors -std=c++11 -triple x86_64-linux-gnu -include-pch %t -verify %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+extern thread_local int a;
+extern _Thread_local int b;
+extern int c;
+
+#else
+
+_Thread_local int a; // expected-error {{thread-local declaration of 'a' with static initialization follows declaration with dynamic initialization}}
+// expected-note@7 {{previous declaration is here}}
+thread_local int b; // expected-error {{thread-local declaration of 'b' with dynamic initialization follows declaration with static initialization}}
+// expected-note@8 {{previous declaration is here}}
+thread_local int c; // expected-error {{thread-local declaration of 'c' follows non-thread-local declaration}}
+// expected-note@9 {{previous declaration is here}}
+
+#endif
diff --git a/test/PCH/typo.cpp b/test/PCH/typo.cpp
index f8161d1..6ab66c2 100644
--- a/test/PCH/typo.cpp
+++ b/test/PCH/typo.cpp
@@ -1,17 +1,14 @@
-
-// In header: expected-note{{'boost::function' declared here}}
-
-
-// In header: expected-note{{'boost::graph::adjacency_list' declared here}}
-
-
-
-adjacent_list<int, int> g; // expected-error{{no template named 'adjacent_list'; did you mean 'boost::graph::adjacency_list'?}}
-Function<int(int)> f; // expected-error{{no template named 'Function'; did you mean 'boost::function'?}}
-
// Without PCH
// RUN: %clang_cc1 -include %S/Inputs/typo.hpp -verify %s
// With PCH
// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/Inputs/typo.hpp
// RUN: %clang_cc1 -include-pch %t -verify %s
+
+adjacent_list<int, int> g;
+// expected-error@-1{{no template named 'adjacent_list'; did you mean 'boost::graph::adjacency_list'?}}
+// expected-note@Inputs/typo.hpp:5{{'boost::graph::adjacency_list' declared here}}
+
+Function<int(int)> f;
+// expected-error@-1{{no template named 'Function'; did you mean 'boost::function'?}}
+// expected-note@Inputs/typo.hpp:2{{'boost::function' declared here}}
diff --git a/test/PCH/typo.m b/test/PCH/typo.m
index c6f0275..876b943 100644
--- a/test/PCH/typo.m
+++ b/test/PCH/typo.m
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -x objective-c-header -emit-pch -o %t %S/Inputs/typo.h
// RUN: %clang_cc1 -include-pch %t -verify %s
-// In header: expected-note{{declared here}}
+
void f() {
[NSstring alloc]; // expected-error{{unknown receiver 'NSstring'; did you mean 'NSString'?}}
+ // expected-note@Inputs/typo.h:3{{declared here}}
}
OpenPOWER on IntegriCloud