diff options
Diffstat (limited to 'test/PCH')
44 files changed, 555 insertions, 64 deletions
diff --git a/test/PCH/Inputs/chain-selectors2.h b/test/PCH/Inputs/chain-selectors2.h index 973fc10..d54244d 100644 --- a/test/PCH/Inputs/chain-selectors2.h +++ b/test/PCH/Inputs/chain-selectors2.h @@ -1,6 +1,6 @@ @interface Y -(void)f; - -(double)f2; + -(void)f2; -(void)e; @end diff --git a/test/PCH/arc.m b/test/PCH/arc.m index 64b390c..466b317 100644 --- a/test/PCH/arc.m +++ b/test/PCH/arc.m @@ -6,9 +6,9 @@ // RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -include-pch %t -fsyntax-only -emit-llvm-only %s // Test error when pch's -fobjc-arc state is different. -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -include-pch %t -fsyntax-only -emit-llvm-only %s 2>&1 | FileCheck -check-prefix=ERR1 %s +// RUN: not %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -include-pch %t -fsyntax-only -emit-llvm-only %s 2>&1 | FileCheck -check-prefix=CHECK-ERR1 %s // RUN: %clang_cc1 -emit-pch -fblocks -triple x86_64-apple-darwin11 -x objective-c-header -o %t %S/Inputs/arc.h -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -include-pch %t -fsyntax-only -emit-llvm-only %s 2>&1 | FileCheck -check-prefix=ERR2 %s +// RUN: not %clang_cc1 -fblocks -triple x86_64-apple-darwin11 -fobjc-arc -include-pch %t -fsyntax-only -emit-llvm-only %s 2>&1 | FileCheck -check-prefix=CHECK-ERR2 %s array0 a0; array1 a1; diff --git a/test/PCH/badpch.c b/test/PCH/badpch.c index f34e3d6..c302329 100644 --- a/test/PCH/badpch.c +++ b/test/PCH/badpch.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -include-pch %S/Inputs/badpch-empty.h.gch %s 2>&1 | FileCheck -check-prefix=CHECK-EMPTY %s -// RUN: %clang_cc1 -fsyntax-only -include-pch %S/Inputs/badpch-dir.h.gch %s 2>&1 | FileCheck -check-prefix=CHECK-DIR %s +// RUN: not %clang_cc1 -fsyntax-only -include-pch %S/Inputs/badpch-empty.h.gch %s 2>&1 | FileCheck -check-prefix=CHECK-EMPTY %s +// RUN: not %clang_cc1 -fsyntax-only -include-pch %S/Inputs/badpch-dir.h.gch %s 2>&1 | FileCheck -check-prefix=CHECK-DIR %s // The purpose of this test is to verify that various invalid PCH files are // reported as such. diff --git a/test/PCH/chain-categories2.m b/test/PCH/chain-categories2.m index f230bf9..50eea2a 100644 --- a/test/PCH/chain-categories2.m +++ b/test/PCH/chain-categories2.m @@ -45,6 +45,7 @@ #else //===----------------------------------------------------------------------===// +// expected-note@30 {{receiver is instance of class declared here}} void f(I* i) { [i meth]; // expected-warning {{not found}} } diff --git a/test/PCH/chain-cxx.cpp b/test/PCH/chain-cxx.cpp index 4b64f51..6e9c174 100644 --- a/test/PCH/chain-cxx.cpp +++ b/test/PCH/chain-cxx.cpp @@ -6,6 +6,9 @@ // With PCH // RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s +// With modules +// RUN: %clang_cc1 -fsyntax-only -verify -fmodules %s -chain-include %s -chain-include %s + // expected-no-diagnostics #ifndef HEADER1 diff --git a/test/PCH/chain-friend-instantiation.cpp b/test/PCH/chain-friend-instantiation.cpp index 294d979..2f042a8 100644 --- a/test/PCH/chain-friend-instantiation.cpp +++ b/test/PCH/chain-friend-instantiation.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 %s -ast-print -o - -chain-include %s -chain-include %s +// RUN: %clang_cc1 %s -ast-print -o - -fmodules -chain-include %s -chain-include %s #if !defined(PASS1) #define PASS1 diff --git a/test/PCH/chain-selectors.m b/test/PCH/chain-selectors.m index 7eae094..f2bfc4b 100644 --- a/test/PCH/chain-selectors.m +++ b/test/PCH/chain-selectors.m @@ -18,9 +18,9 @@ void bar() { // FIXME: Can't verify notes in headers //[a f2]; - (void)@selector(x); // expected-warning {{unimplemented selector}} - (void)@selector(y); // expected-warning {{unimplemented selector}} - (void)@selector(e); // expected-warning {{unimplemented selector}} + (void)@selector(x); // expected-warning {{creating selector for nonexistent method 'x'}} + (void)@selector(y); // expected-warning {{creating selector for nonexistent method 'y'}} + (void)@selector(e); // expected-warning {{creating selector for nonexistent method 'e'}} } @implementation X (Blah) diff --git a/test/PCH/check-deserializations.cpp b/test/PCH/check-deserializations.cpp index 9f73c95..e4dafb7 100644 --- a/test/PCH/check-deserializations.cpp +++ b/test/PCH/check-deserializations.cpp @@ -1,20 +1,34 @@ -// RUN: %clang_cc1 -emit-pch -o %t %s -// RUN: %clang_cc1 -error-on-deserialized-decl S1_method -include-pch %t -emit-llvm-only %s +// RUN: %clang_cc1 -emit-pch -o %t.1 %s +// RUN: %clang_cc1 -error-on-deserialized-decl S1_keyfunc -error-on-deserialized-decl S3 -include-pch %t.1 -emit-pch -o %t.2 %s +// RUN: %clang_cc1 -error-on-deserialized-decl S1_method -error-on-deserialized-decl S3 -include-pch %t.2 -emit-llvm-only %s -#ifndef HEADER -#define HEADER +#ifndef HEADER1 +#define HEADER1 // Header. struct S1 { - void S1_method(); // This should not be deserialized. + void S1_method(); virtual void S1_keyfunc(); }; +struct S3 {}; + +struct S2 { + operator S3(); +}; + +#elif !defined(HEADER2) +#define HEADER2 + +// Chained PCH. +S1 *s1; +S2 *s2; #else -// Using the header. -void test(S1*) { +// Using the headers. + +void test(S1*, S2*) { } #endif diff --git a/test/PCH/cxx-friends.cpp b/test/PCH/cxx-friends.cpp index f7d45ce..9c75f92 100644 --- a/test/PCH/cxx-friends.cpp +++ b/test/PCH/cxx-friends.cpp @@ -3,7 +3,11 @@ // Test with pch. // RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-friends.h -// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s -error-on-deserialized-decl doNotDeserialize + +// Test with modules. +// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-friends.h -fmodules +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s -error-on-deserialized-decl doNotDeserialize -fmodules // expected-no-diagnostics @@ -21,3 +25,5 @@ public: } }; int k = PR12585::future_base::setter<int>().f(); + +Lazy::S *p; diff --git a/test/PCH/cxx-friends.h b/test/PCH/cxx-friends.h index 05dcc96..2d20a4d 100644 --- a/test/PCH/cxx-friends.h +++ b/test/PCH/cxx-friends.h @@ -16,3 +16,28 @@ namespace PR12585 { int k; }; } + +namespace Lazy { + struct S { + friend void doNotDeserialize(); + }; +} + +// Reduced testcase from libc++'s <valarray>. Used to crash with modules +// enabled. +namespace std { + +template <class T> struct valarray; + +template <class T> struct valarray { + valarray(); + template <class U> friend struct valarray; + template <class U> friend U *begin(valarray<U> &v); +}; + +struct gslice { + valarray<int> size; + gslice() {} +}; + +} diff --git a/test/PCH/cxx-member-init.cpp b/test/PCH/cxx-member-init.cpp index 20594d5..78fd744 100644 --- a/test/PCH/cxx-member-init.cpp +++ b/test/PCH/cxx-member-init.cpp @@ -13,6 +13,15 @@ struct S { S *that = this; }; template<typename T> struct X { T t {0}; }; + +struct v_t { }; + +struct m_t +{ + struct { v_t v; }; + m_t() { } +}; + #endif #ifdef SOURCE @@ -20,6 +29,11 @@ S s; struct E { explicit E(int); }; X<E> x; + +m_t *test() { + return new m_t; +} + #elif HEADER #undef HEADER #define SOURCE diff --git a/test/PCH/cxx-namespaces.cpp b/test/PCH/cxx-namespaces.cpp index e0ff27c..e0feaab 100644 --- a/test/PCH/cxx-namespaces.cpp +++ b/test/PCH/cxx-namespaces.cpp @@ -3,10 +3,23 @@ // Test with pch. // RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-namespaces.h -// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -ast-dump -ast-dump-lookups -ast-dump-filter N %s | FileCheck %s + +// Test with modules. +// RUN: %clang_cc1 -fmodules -x c++-header -emit-pch -o %t %S/cxx-namespaces.h +// RUN: %clang_cc1 -fmodules -include-pch %t -fsyntax-only -verify %s +// RUN: %clang_cc1 -fmodules -include-pch %t -fsyntax-only -ast-dump -ast-dump-lookups -ast-dump-filter N %s | FileCheck %s // expected-no-diagnostics void m() { N::x = 0; + N::f(); } + +// namespace 'N' should contain only two declarations of 'f'. + +// CHECK: DeclarationName 'f' +// CHECK-NEXT: |-Function {{.*}} 'f' 'void ( +// CHECK-NEXT: `-Function {{.*}} 'f' 'void ( diff --git a/test/PCH/cxx-namespaces.h b/test/PCH/cxx-namespaces.h index f338953..26d75a0 100644 --- a/test/PCH/cxx-namespaces.h +++ b/test/PCH/cxx-namespaces.h @@ -4,4 +4,7 @@ namespace N { namespace { int x; } + + void f(); + void f(int); } diff --git a/test/PCH/cxx-templates.cpp b/test/PCH/cxx-templates.cpp index 58c4c17..e5ddd86 100644 --- a/test/PCH/cxx-templates.cpp +++ b/test/PCH/cxx-templates.cpp @@ -1,13 +1,21 @@ // Test this without pch. // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h -verify %s -ast-dump -o - -// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include %S/cxx-templates.h %s -emit-llvm -o - -DNO_ERRORS | FileCheck %s // Test with pch. // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h // RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include-pch %t -verify %s -ast-dump -o - -// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize | FileCheck %s +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize -DNO_ERRORS | FileCheck %s -// expected-no-diagnostics +// Test with modules. +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fmodules -x c++-header -emit-pch -o %t %S/cxx-templates.h +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fmodules -include-pch %t -verify %s -ast-dump -o - +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fmodules -include-pch %t %s -emit-llvm -o - -error-on-deserialized-decl doNotDeserialize -DNO_ERRORS | FileCheck %s + +// Test with pch and delayed template parsing. +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fdelayed-template-parsing -fexceptions -x c++-header -emit-pch -o %t %S/cxx-templates.h +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t -verify %s -ast-dump -o - +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fdelayed-template-parsing -fexceptions -include-pch %t %s -emit-llvm -o - -DNO_ERRORS | FileCheck %s // CHECK: define weak_odr void @_ZN2S4IiE1mEv // CHECK: define linkonce_odr void @_ZN2S3IiE1mEv @@ -85,3 +93,18 @@ namespace rdar13135282 { __mt_alloc<> mt = __mt_alloc<>(); } } + +void CallDependentSpecializedFunc(DependentSpecializedFuncClass<int> &x) { + DependentSpecializedFunc(x); +} + +namespace cyclic_module_load { + extern std::valarray<int> x; + std::valarray<int> y(x); +} + +#ifndef NO_ERRORS +// expected-error@cxx-templates.h:305 {{incomplete}} +template int local_extern::f<int[]>(); // expected-note {{in instantiation of}} +#endif +template int local_extern::g<int[]>(); diff --git a/test/PCH/cxx-templates.h b/test/PCH/cxx-templates.h index e672b0b..992f478 100644 --- a/test/PCH/cxx-templates.h +++ b/test/PCH/cxx-templates.h @@ -269,3 +269,45 @@ template<typename T> struct ContainsDoNotDeserialize2 { }; template<typename T> int ContainsDoNotDeserialize<T>::doNotDeserialize = 0; template<typename T> void ContainsDoNotDeserialize2<T>::doNotDeserialize() {} + + +template<typename T> void DependentSpecializedFunc(T x) { x.foo(); } +template<typename T> class DependentSpecializedFuncClass { + void foo() {} + friend void DependentSpecializedFunc<>(DependentSpecializedFuncClass); +}; + +namespace cyclic_module_load { + // Reduced from a libc++ modules crasher. + namespace std { + template<class> class mask_array; + template<class> class valarray { + public: + valarray(const valarray &v); + }; + + class gslice { + valarray<int> x; + valarray<int> stride() const { return x; } + }; + + template<class> class mask_array { + template<class> friend class valarray; + }; + } +} + +namespace local_extern { + template<typename T> int f() { + extern int arr[3]; + { + extern T arr; + return sizeof(arr); + } + } + template<typename T> int g() { + extern int arr[3]; + extern T arr; + return sizeof(arr); + } +} diff --git a/test/PCH/cxx-traits.cpp b/test/PCH/cxx-traits.cpp index 938f36f..ffdfccc 100644 --- a/test/PCH/cxx-traits.cpp +++ b/test/PCH/cxx-traits.cpp @@ -2,9 +2,11 @@ // RUN: %clang_cc1 -include %S/cxx-traits.h -std=c++11 -fsyntax-only -verify %s // RUN: %clang_cc1 -x c++-header -std=c++11 -emit-pch -o %t %S/cxx-traits.h -// RUN: %clang_cc1 -std=c++11 -include-pch %t -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -include-pch %t -DPCH -fsyntax-only -verify %s +#ifdef PCH // expected-no-diagnostics +#endif bool _Is_pod_comparator = __is_pod<int>::__value; bool _Is_empty_check = __is_empty<int>::__value; diff --git a/test/PCH/cxx-traits.h b/test/PCH/cxx-traits.h index 8b62002..836804e 100644 --- a/test/PCH/cxx-traits.h +++ b/test/PCH/cxx-traits.h @@ -1,12 +1,12 @@ // Header for PCH test cxx-traits.cpp template<typename _Tp> -struct __is_pod { +struct __is_pod { // expected-warning {{keyword '__is_pod' will be treated as an identifier for the remainder of the translation unit}} enum { __value }; }; template<typename _Tp> -struct __is_empty { +struct __is_empty { // expected-warning {{keyword '__is_empty' will be treated as an identifier for the remainder of the translation unit}} enum { __value }; }; diff --git a/test/PCH/cxx-typeid.cpp b/test/PCH/cxx-typeid.cpp index 534863a..6e62220 100644 --- a/test/PCH/cxx-typeid.cpp +++ b/test/PCH/cxx-typeid.cpp @@ -1,8 +1,8 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/cxx-typeid.h -fsyntax-only -verify %s +// RUN: %clang_cc1 -include %S/cxx-typeid.h -fsyntax-only -stdlib=libstdc++ -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 +// RUN: %clang_cc1 -x c++-header -emit-pch -stdlib=libstdc++ -o %t.pch %S/cxx-typeid.h +// RUN: %clang_cc1 -include-pch %t.pch -fsyntax-only -stdlib=libstdc++ -verify %s // expected-no-diagnostics diff --git a/test/PCH/cxx11-lambdas.mm b/test/PCH/cxx11-lambdas.mm index c00ec63..c455051 100644 --- a/test/PCH/cxx11-lambdas.mm +++ b/test/PCH/cxx11-lambdas.mm @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -pedantic-errors -fblocks -std=c++11 -emit-pch %s -o %t-cxx11 -// RUN: %clang_cc1 -ast-print -pedantic-errors -fblocks -std=c++11 -include-pch %t-cxx11 %s | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: %clang_cc1 -pedantic-errors -fblocks -std=c++1y -emit-pch %s -o %t-cxx11 +// RUN: %clang_cc1 -ast-print -pedantic-errors -fblocks -std=c++1y -include-pch %t-cxx11 %s | FileCheck -check-prefix=CHECK-PRINT %s #ifndef HEADER_INCLUDED @@ -33,6 +33,11 @@ inline int to_block_pointer(int n) { return block(17); } +template<typename T> +int init_capture(T t) { + return [&, x(t)] { return sizeof(x); }; +} + #else // CHECK-PRINT: T add_slowly @@ -45,4 +50,8 @@ int add(int x, int y) { // CHECK-PRINT: inline int add_int_slowly_twice // CHECK-PRINT: lambda = [&] (int z) + +// CHECK-PRINT: init_capture +// CHECK-PRINT: [&, x( t )] + #endif diff --git a/test/PCH/cxx1y-deduced-return-type.cpp b/test/PCH/cxx1y-deduced-return-type.cpp new file mode 100644 index 0000000..a61dda2 --- /dev/null +++ b/test/PCH/cxx1y-deduced-return-type.cpp @@ -0,0 +1,34 @@ +// No PCH: +// RUN: %clang_cc1 -pedantic -std=c++1y -include %s -include %s -verify %s +// +// With chained PCH: +// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t.a +// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.a -emit-pch %s -o %t.b +// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.b -verify %s + +// expected-no-diagnostics + +#if !defined(HEADER1) +#define HEADER1 + +auto &f(int &); + +template<typename T> decltype(auto) g(T &t) { + return f(t); +} + +#elif !defined(HEADER2) +#define HEADER2 + +// Ensure that this provides an update record for the type of HEADER1's 'f', +// so that HEADER1's 'g' can successfully call it. +auto &f(int &n) { + return n; +} + +#else + +int n; +int &k = g(n); + +#endif diff --git a/test/PCH/cxx1y-init-captures.cpp b/test/PCH/cxx1y-init-captures.cpp new file mode 100644 index 0000000..3c8fc14 --- /dev/null +++ b/test/PCH/cxx1y-init-captures.cpp @@ -0,0 +1,28 @@ +// No PCH: +// RUN: %clang_cc1 -pedantic -std=c++1y -include %s -verify %s +// +// With PCH: +// 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 +#define HEADER + +auto counter = [a(0)] () mutable { return a++; }; +int x = counter(); + +template<typename T> void f(T t) { + [t(t)] { int n = t; } (); +} + +#else + +int y = counter(); + +void g() { + f(0); // ok + // expected-error@15 {{lvalue of type 'const char *const'}} + f("foo"); // expected-note {{here}} +} + +#endif diff --git a/test/PCH/cxx1y-lambdas.mm b/test/PCH/cxx1y-lambdas.mm new file mode 100644 index 0000000..ee4a2ba --- /dev/null +++ b/test/PCH/cxx1y-lambdas.mm @@ -0,0 +1,58 @@ +// RUN: %clang_cc1 -pedantic-errors -fblocks -std=c++1y -emit-pch %s -o %t-cxx1y
+// RUN: %clang_cc1 -ast-print -pedantic-errors -fblocks -std=c++1y -include-pch %t-cxx1y %s | FileCheck -check-prefix=CHECK-PRINT %s
+
+#ifndef HEADER_INCLUDED
+
+#define HEADER_INCLUDED
+template<typename T>
+T add_slowly(const T& x, const T &y) {
+ return [](auto z, int y = 0) { return z + y; }(5);
+};
+
+inline int add_int_slowly_twice(int x, int y) {
+ int i = add_slowly(x, y);
+ auto lambda = [](auto z) { return z + z; };
+ return i + lambda(y);
+}
+
+inline int sum_array(int n) {
+ auto lambda = [](auto N) -> int {
+ int sum = 0;
+ int array[5] = { 1, 2, 3, 4, 5};
+
+ for (unsigned I = 0; I < N; ++I)
+ sum += array[N];
+ return sum;
+ };
+
+ return lambda(n);
+}
+
+inline int to_block_pointer(int n) {
+ auto lambda = [=](int m) { return n + m; };
+ int (^block)(int) = lambda;
+ return block(17);
+}
+
+template<typename T>
+int init_capture(T t) {
+ return [&, x(t)] { return sizeof(x); };
+}
+
+#else
+
+// CHECK-PRINT: T add_slowly
+// CHECK-PRINT: return []
+template float add_slowly(const float&, const float&);
+
+int add(int x, int y) {
+ return add_int_slowly_twice(x, y) + sum_array(4) + to_block_pointer(5);
+}
+
+// CHECK-PRINT: inline int add_int_slowly_twice
+// CHECK-PRINT: lambda = [] ($auto-0-0 z
+
+// CHECK-PRINT: init_capture
+// CHECK-PRINT: [&, x( t )]
+
+#endif
diff --git a/test/PCH/cxx1y-variable-templates.cpp b/test/PCH/cxx1y-variable-templates.cpp new file mode 100644 index 0000000..77eeea2 --- /dev/null +++ b/test/PCH/cxx1y-variable-templates.cpp @@ -0,0 +1,171 @@ +// No PCH: +// RUN: %clang_cc1 -pedantic -std=c++1y -include %s -include %s -verify %s -DNONPCH +// RUN: %clang_cc1 -pedantic -std=c++1y -include %s -include %s -verify %s -DNONPCH -DERROR +// +// With PCH: +// RUN: %clang_cc1 -pedantic -std=c++1y -emit-pch %s -o %t.a -DHEADER1 +// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.a -emit-pch %s -o %t.b -DHEADER2 +// RUN: %clang_cc1 -pedantic -std=c++1y -include-pch %t.b -verify %s -DHEADERUSE + +#ifndef ERROR +// expected-no-diagnostics +#endif + +#ifdef NONPCH +#if !defined(HEADER1) +#define HEADER1 +#undef HEADER2 +#undef HEADERUSE +#elif !defined(HEADER2) +#define HEADER2 +#undef HEADERUSE +#else +#define HEADERUSE +#undef HEADER1 +#undef HEADER2 +#endif +#endif + + +// *** HEADER1: First header file +#if defined(HEADER1) && !defined(HEADER2) && !defined(HEADERUSE) + +template<typename T> T var0a = T(); +template<typename T> extern T var0b; + +namespace join { + template<typename T> T va = T(100); + template<typename T> extern T vb; + + namespace diff_types { +#ifdef ERROR + template<typename T> extern float err0; + template<typename T> extern T err1; +#endif + template<typename T> extern T def; + } + +} + +namespace spec { + template<typename T> constexpr T va = T(10); + template<> constexpr float va<float> = 1.5; + template constexpr int va<int>; + + template<typename T> T vb = T(); + template<> constexpr float vb<float> = 1.5; + + template<typename T> T vc = T(); + + template<typename T> constexpr T vd = T(10); + template<typename T> T* vd<T*> = new T(); +} + +namespace spec_join1 { + template<typename T> T va = T(10); + template<> extern float va<float>; + extern template int va<int>; + + template<typename T> T vb = T(10); + template<> extern float vb<float>; + + template<typename T> T vc = T(10); + + template<typename T> T vd = T(10); + template<typename T> extern T* vd<T*>; +} + +#endif + + +// *** HEADER2: Second header file -- including HEADER1 +#if defined(HEADER2) && !defined(HEADERUSE) + +namespace join { + template<typename T> extern T va; + template<> constexpr float va<float> = 2.5; + + template<typename T> T vb = T(100); + + namespace diff_types { +#ifdef ERROR + template<typename T> extern T err0; // expected-error {{redefinition of 'err0' with a different type: 'T' vs 'float'}} // expected-note@42 {{previous definition is here}} + template<typename T> extern float err1; // expected-error {{redefinition of 'err1' with a different type: 'float' vs 'T'}} // expected-note@43 {{previous definition is here}} +#endif + template<typename T> extern T def; + } +} + +namespace spec_join1 { + template<typename T> extern T va; + template<> float va<float> = 1.5; + extern template int va<int>; + + template<> float vb<float> = 1.5; + template int vb<int>; + + template<> float vc<float> = 1.5; + template int vc<int>; + + template<typename T> extern T vd; + template<typename T> T* vd<T*> = new T(); +} + +#endif + +// *** HEADERUSE: File using both header files -- including HEADER2 +#ifdef HEADERUSE + +template int var0a<int>; +float fvara = var0a<float>; + +template<typename T> extern T var0a; + +template<typename T> T var0b = T(); +template int var0b<int>; +float fvarb = var0b<float>; + +namespace join { + template const int va<const int>; + template<> const int va<int> = 50; + static_assert(va<float> == 2.5, ""); + static_assert(va<int> == 50, ""); + + template<> constexpr float vb<float> = 2.5; + template const int vb<const int>; + static_assert(vb<float> == 2.5, ""); + static_assert(vb<const int> == 100, ""); + + namespace diff_types { + template<typename T> T def = T(); + } + +} + +namespace spec { + static_assert(va<float> == 1.5, ""); + static_assert(va<int> == 10, ""); + + template<typename T> T* vb<T*> = new T(); + int* intpb = vb<int*>; + static_assert(vb<float> == 1.5, ""); + + template<typename T> T* vc<T*> = new T(); + template<> constexpr float vc<float> = 1.5; + int* intpc = vc<int*>; + static_assert(vc<float> == 1.5, ""); + + char* intpd = vd<char*>; +} + +namespace spec_join1 { + template int va<int>; + int a = va<int>; + + template<typename T> extern T vb; + int b = vb<int>; + + int* intpb = vd<int*>; +} + +#endif diff --git a/test/PCH/debug-info-limited-struct.c b/test/PCH/debug-info-limited-struct.c new file mode 100644 index 0000000..9d0ed26 --- /dev/null +++ b/test/PCH/debug-info-limited-struct.c @@ -0,0 +1,4 @@ +// RUN: %clang_cc1 -emit-pch -o %t %S/debug-info-limited-struct.h +// RUN: %clang_cc1 -include-pch %t -emit-llvm %s -g -o - | FileCheck %s + +// CHECK-DAG: [ DW_TAG_structure_type ] [foo] {{.*}} [def] diff --git a/test/PCH/debug-info-limited-struct.h b/test/PCH/debug-info-limited-struct.h new file mode 100644 index 0000000..593e722 --- /dev/null +++ b/test/PCH/debug-info-limited-struct.h @@ -0,0 +1,8 @@ +struct foo { + int i; +}; + +void func() { + struct foo *f; + f->i = 3; +} diff --git a/test/PCH/exprs.h b/test/PCH/exprs.h index d08b1f6..d6735a7 100644 --- a/test/PCH/exprs.h +++ b/test/PCH/exprs.h @@ -102,6 +102,10 @@ typedef typeof(__builtin_choose_expr(17 > 19, d0, 1)) choose_expr; // ShuffleVectorExpr typedef typeof(__builtin_shufflevector(vec2, vec2b, 2, 1)) shuffle_expr; +// ConvertVectorExpr +typedef __attribute__(( ext_vector_type(2) )) float float2; +typedef typeof(__builtin_convertvector(vec2, float2)) convert_expr; + // GenericSelectionExpr typedef typeof(_Generic(i, char*: 0, int: 0., default: hello)) generic_selection_expr; diff --git a/test/PCH/external-defs.c b/test/PCH/external-defs.c index 5097859..5c2582a 100644 --- a/test/PCH/external-defs.c +++ b/test/PCH/external-defs.c @@ -3,7 +3,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -include-pch %t.pch -emit-llvm -o %t %s // RUN: grep "@x = common global i32 0" %t | count 1 -// RUN: grep "@z" %t | count 0 +// RUN: not grep "@z" %t // RUN: grep "@x2 = global i32 19" %t | count 1 int x2 = 19; diff --git a/test/PCH/floating-literal.c b/test/PCH/floating-literal.c index 7bf10d4..738e45a 100644 --- a/test/PCH/floating-literal.c +++ b/test/PCH/floating-literal.c @@ -7,12 +7,12 @@ // targets with 128-bit IEEE long doubles. long double foo = 1.0E4000L; -// CHECK: long double foo = 1.0E+4000L; +// CHECK: long double foo = 1.00000000000000000000000000000000004E+4000L; // Just as well check the others are still sane while we're here... double bar = 1.0E300; -// CHECK: double bar = 1.0E+300; +// CHECK: double bar = 1.0000000000000001E+300; float wibble = 1.0E40; // CHECK: float wibble = 1.0E+40; diff --git a/test/PCH/irgen-rdar13114142.mm b/test/PCH/irgen-rdar13114142.mm index bd523c2..7a9cfba 100644 --- a/test/PCH/irgen-rdar13114142.mm +++ b/test/PCH/irgen-rdar13114142.mm @@ -1,5 +1,5 @@ // RUN: %clang_cc1 %s -emit-pch -o %t.pch -// RUN: %clang_cc1 %s -emit-llvm %s -include-pch %t.pch -o - | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -include-pch %t.pch -o - | FileCheck %s #ifndef HEADER #define HEADER diff --git a/test/PCH/line-directive.c b/test/PCH/line-directive.c index 4710c40..7d59c62 100644 --- a/test/PCH/line-directive.c +++ b/test/PCH/line-directive.c @@ -1,9 +1,9 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/line-directive.h -fsyntax-only %s 2>&1|grep "25:5" +// RUN: not %clang_cc1 -include %S/line-directive.h -fsyntax-only %s 2>&1|grep "25:5" // Test with pch. // RUN: %clang_cc1 -emit-pch -o %t %S/line-directive.h -// RUN: %clang_cc1 -include-pch %t -fsyntax-only %s 2>&1|grep "25:5" +// RUN: not %clang_cc1 -include-pch %t -fsyntax-only %s 2>&1|grep "25:5" double x; // expected-error{{redefinition of 'x' with a different type}} diff --git a/test/PCH/modified-header-error.c b/test/PCH/modified-header-error.c index 4ad3faf..8ab38e1 100644 --- a/test/PCH/modified-header-error.c +++ b/test/PCH/modified-header-error.c @@ -4,7 +4,7 @@ // RUN: cp %s %t.dir/t.c // RUN: %clang_cc1 -x c-header %t.dir/header1.h -emit-pch -o %t.pch // RUN: echo >> %t.dir/header2.h -// RUN: %clang_cc1 %t.dir/t.c -include-pch %t.pch -fsyntax-only 2>&1 | FileCheck %s +// RUN: not %clang_cc1 %t.dir/t.c -include-pch %t.pch -fsyntax-only 2>&1 | FileCheck %s #include "header2.h" diff --git a/test/PCH/objc_container.m b/test/PCH/objc_container.m index aafe6a9..0f25d32 100644 --- a/test/PCH/objc_container.m +++ b/test/PCH/objc_container.m @@ -4,8 +4,8 @@ // Test with pch. // RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_container.h // RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s -// RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=PRINT %s -// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=IR %s +// RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-IR %s // expected-no-diagnostics diff --git a/test/PCH/objc_import.h b/test/PCH/objc_import.h index 8af87ab..4646e16 100644 --- a/test/PCH/objc_import.h +++ b/test/PCH/objc_import.h @@ -5,3 +5,14 @@ - (void)instMethod; @end +@class NewID1; +@compatibility_alias OldID1 NewID1; +@class OldID1; +@class OldID1; + +@class NewID2; +@compatibility_alias OldID2 NewID2; +@class OldID2; +@interface OldID2 +-(void)meth; +@end diff --git a/test/PCH/objc_import.m b/test/PCH/objc_import.m index c7dd805..724c822 100644 --- a/test/PCH/objc_import.m +++ b/test/PCH/objc_import.m @@ -15,3 +15,18 @@ void func() { xx = [TestPCH alloc]; [xx instMethod]; } + +// rdar://14112291 +@class NewID1; +void foo1(NewID1 *p); +void bar1(OldID1 *p) { + foo1(p); +} +@class NewID2; +void foo2(NewID2 *p) { + [p meth]; +} +void bar2(OldID2 *p) { + foo2(p); + [p meth]; +} diff --git a/test/PCH/objc_literals.m b/test/PCH/objc_literals.m index b73c3be..f96d4af 100644 --- a/test/PCH/objc_literals.m +++ b/test/PCH/objc_literals.m @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -emit-pch -o %t %s // RUN: %clang_cc1 -include-pch %t -verify %s -// RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=PRINT %s -// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=IR %s +// RUN: %clang_cc1 -include-pch %t -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-IR %s // expected-no-diagnostics @@ -44,18 +44,18 @@ static inline void test_numeric_literals() { // CHECK-PRINT: id intlit = @17 // CHECK-IR: {{call.*17}} id intlit = @17; - // CHECK-PRINT: id floatlit = @17.45 + // CHECK-PRINT: id floatlit = @17.449999999999999 // CHECK-IR: {{call.*1.745}} id floatlit = @17.45; } static inline void test_array_literals() { - // CHECK-PRINT: id arraylit = @[ @17, @17.45 + // CHECK-PRINT: id arraylit = @[ @17, @17.449999999999999 id arraylit = @[@17, @17.45]; } static inline void test_dictionary_literals() { - // CHECK-PRINT: id dictlit = @{ @17 : {{@17.45[^,]*}}, @"hello" : @"world" }; + // CHECK-PRINT: id dictlit = @{ @17 : {{@17.449999999999999[^,]*}}, @"hello" : @"world" }; id dictlit = @{@17 : @17.45, @"hello" : @"world" }; } diff --git a/test/PCH/objc_literals.mm b/test/PCH/objc_literals.mm index ef95294..59f3381 100644 --- a/test/PCH/objc_literals.mm +++ b/test/PCH/objc_literals.mm @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -emit-pch -x objective-c++ -std=c++0x -o %t %s // RUN: %clang_cc1 -include-pch %t -x objective-c++ -std=c++0x -verify %s -// RUN: %clang_cc1 -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=PRINT %s -// RUN: %clang_cc1 -include-pch %t -x objective-c++ -std=c++0x -emit-llvm -o - %s | FileCheck -check-prefix=IR %s +// RUN: %clang_cc1 -include-pch %t -x objective-c++ -std=c++0x -ast-print %s | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: %clang_cc1 -include-pch %t -x objective-c++ -std=c++0x -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-IR %s // expected-no-diagnostics diff --git a/test/PCH/objcxx-ivar-class.mm b/test/PCH/objcxx-ivar-class.mm index 8214957..a83d7e7 100644 --- a/test/PCH/objcxx-ivar-class.mm +++ b/test/PCH/objcxx-ivar-class.mm @@ -1,9 +1,9 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/objcxx-ivar-class.h -verify %s -emit-llvm -o - | FileCheck %s +// RUN: not %clang_cc1 -include %S/objcxx-ivar-class.h -verify %s -emit-llvm -o - | FileCheck %s // Test with pch. // RUN: %clang_cc1 -x objective-c++-header -emit-pch -o %t %S/objcxx-ivar-class.h -// RUN: %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s +// RUN: not %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // CHECK: [C position] // CHECK: call {{.*}} @_ZN1SC1ERKS_ diff --git a/test/PCH/pch-dir.c b/test/PCH/pch-dir.c index ae841ce..2ac10ea 100644 --- a/test/PCH/pch-dir.c +++ b/test/PCH/pch-dir.c @@ -3,14 +3,14 @@ // RUN: %clang -x c-header %S/pch-dir.h -DFOO=bar -o %t.h.gch/cbar.gch // RUN: %clang -x c++-header -std=c++98 %S/pch-dir.h -o %t.h.gch/cpp.gch // RUN: %clang -include %t.h -DFOO=foo -fsyntax-only %s -Xclang -print-stats 2> %t.clog -// RUN: FileCheck -check-prefix=C %s < %t.clog +// RUN: FileCheck -check-prefix=CHECK-C %s < %t.clog // RUN: %clang -include %t.h -DFOO=bar -DBAR=bar -fsyntax-only %s -Xclang -ast-print > %t.cbarlog -// RUN: FileCheck -check-prefix=CBAR %s < %t.cbarlog +// RUN: FileCheck -check-prefix=CHECK-CBAR %s < %t.cbarlog // RUN: %clang -x c++ -include %t.h -std=c++98 -fsyntax-only %s -Xclang -print-stats 2> %t.cpplog -// RUN: FileCheck -check-prefix=CPP %s < %t.cpplog +// RUN: FileCheck -check-prefix=CHECK-CPP %s < %t.cpplog // RUN: not %clang -x c++ -std=c++11 -include %t.h -fsyntax-only %s 2> %t.cpp11log -// RUN: FileCheck -check-prefix=CPP11 %s < %t.cpp11log +// RUN: FileCheck -check-prefix=CHECK-CPP11 %s < %t.cpp11log // CHECK-CBAR: int bar int FOO; diff --git a/test/PCH/pragma-diag-section.cpp b/test/PCH/pragma-diag-section.cpp index 627156f..eea6bd7 100644 --- a/test/PCH/pragma-diag-section.cpp +++ b/test/PCH/pragma-diag-section.cpp @@ -1,20 +1,20 @@ // Test this without pch. -// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only +// RUN: %clang_cc1 %s -include %s -verify -fsyntax-only -Wuninitialized // Test with pch. // RUN: %clang_cc1 %s -emit-pch -o %t -// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only +// RUN: %clang_cc1 %s -include-pch %t -verify -fsyntax-only -Wuninitialized #ifndef HEADER #define HEADER #pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wtautological-compare" +#pragma clang diagnostic ignored "-Wuninitialized" template <typename T> struct TS1 { void m() { - T a = 0; - T b = a==a; + T a; + T b = a; } }; #pragma clang diagnostic pop @@ -25,8 +25,10 @@ struct TS1 { template <typename T> struct TS2 { void m() { - T a = 0; - T b = a==a; // expected-warning {{self-comparison always evaluates to true}} expected-note@39 {{in instantiation of member function}} + T a; + T b = a; // expected-warning {{variable 'a' is uninitialized}} \ + expected-note@41 {{in instantiation of member function}} \ + expected-note@28 {{initialize the variable 'a' to silence}} } }; diff --git a/test/PCH/pragma-weak.c b/test/PCH/pragma-weak.c index 18b45c8..1a8724c 100644 --- a/test/PCH/pragma-weak.c +++ b/test/PCH/pragma-weak.c @@ -1,9 +1,9 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/pragma-weak.h %s -verify -emit-llvm -o - | FileCheck %s +// RUN: not %clang_cc1 -include %S/pragma-weak.h %s -verify -emit-llvm -o - | FileCheck %s // Test with pch. // RUN: %clang_cc1 -x c-header -emit-pch -o %t %S/pragma-weak.h -// RUN: %clang_cc1 -include-pch %t %s -verify -emit-llvm -o - | FileCheck %s +// RUN: not %clang_cc1 -include-pch %t %s -verify -emit-llvm -o - | FileCheck %s // CHECK: @weakvar = weak global i32 0 int weakvar; diff --git a/test/PCH/preamble.c b/test/PCH/preamble.c index 6a61fa1..7344f54 100644 --- a/test/PCH/preamble.c +++ b/test/PCH/preamble.c @@ -1,7 +1,7 @@ // Check that using the preamble option actually skips the preamble. // RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/preamble.h -DFOO=f -// RUN: %clang_cc1 -include-pch %t -preamble-bytes=317,1 -DFOO=f -verify %s -emit-llvm -o - | FileCheck %s +// RUN: not %clang_cc1 -include-pch %t -preamble-bytes=317,1 -DFOO=f -verify %s -emit-llvm -o - | FileCheck %s float f(int); // Not an error, because we skip this via the preamble! diff --git a/test/PCH/pth.c b/test/PCH/pth.c index 1262f8a..6f2e4fc 100644 --- a/test/PCH/pth.c +++ b/test/PCH/pth.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-pth -o %t %S/pth.h -// RUN: %clang_cc1 -triple i386-unknown-unknown -include-pth %t -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: not %clang_cc1 -triple i386-unknown-unknown -include-pth %t -fsyntax-only %s 2>&1 | FileCheck %s #error This is the only diagnostic // CHECK: This is the only diagnostic -// CHECK: 1 error generated.
\ No newline at end of file +// CHECK: 1 error generated. diff --git a/test/PCH/rdar10830559.cpp b/test/PCH/rdar10830559.cpp index b9b6437..aa19da4 100644 --- a/test/PCH/rdar10830559.cpp +++ b/test/PCH/rdar10830559.cpp @@ -8,7 +8,7 @@ // rdar://10830559 -#pragma ms_struct on +//#pragma ms_struct on template< typename T > class Templated diff --git a/test/PCH/remap-file-from-pch.cpp b/test/PCH/remap-file-from-pch.cpp index 8b965cf..0172853 100644 --- a/test/PCH/remap-file-from-pch.cpp +++ b/test/PCH/remap-file-from-pch.cpp @@ -1,7 +1,7 @@ // %clang_cc1 -remap-file "%s;%S/Inputs/remapped-file" -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXIST %s // RUN: %clang_cc1 -x c++-header %s.h -emit-pch -o %t.pch -// RUN: %clang_cc1 %s -include-pch %t.pch -remap-file "%s.h;%s.remap.h" -fsyntax-only 2>&1 | FileCheck %s +// RUN: not %clang_cc1 %s -include-pch %t.pch -remap-file "%s.h;%s.remap.h" -fsyntax-only 2>&1 | FileCheck %s const char *str = STR; int ge = zool; |