diff options
Diffstat (limited to 'test/PCH')
-rw-r--r-- | test/PCH/cxx-alias-decl.cpp | 20 | ||||
-rw-r--r-- | test/PCH/cxx-alias-decl.h | 11 | ||||
-rw-r--r-- | test/PCH/cxx-for-range.cpp | 6 | ||||
-rw-r--r-- | test/PCH/cxx-member-init.cpp | 22 | ||||
-rw-r--r-- | test/PCH/cxx-reference.cpp | 6 | ||||
-rw-r--r-- | test/PCH/cxx-static_assert.cpp | 15 | ||||
-rw-r--r-- | test/PCH/cxx-static_assert.h | 9 | ||||
-rw-r--r-- | test/PCH/cxx0x-default-delete.cpp | 23 | ||||
-rw-r--r-- | test/PCH/cxx0x-delegating-ctors.cpp | 20 | ||||
-rw-r--r-- | test/PCH/modified-header-error.c | 11 | ||||
-rw-r--r-- | test/PCH/objc_methods.h | 2 | ||||
-rw-r--r-- | test/PCH/objc_methods.m | 2 | ||||
-rw-r--r-- | test/PCH/objcxx-ivar-class.mm | 2 |
13 files changed, 128 insertions, 21 deletions
diff --git a/test/PCH/cxx-alias-decl.cpp b/test/PCH/cxx-alias-decl.cpp new file mode 100644 index 000000000000..e30311c58b7b --- /dev/null +++ b/test/PCH/cxx-alias-decl.cpp @@ -0,0 +1,20 @@ +// Test this without pch. +// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-alias-decl.h -fsyntax-only -emit-llvm -o - %s + +// Test with pch. +// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-alias-decl.h +// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s + +template struct T<S>; +C<A>::A<char> a; + +using T1 = decltype(a); +using T1 = D<int, char>; + +using T2 = B<A>; +using T2 = S; + +using A = int; +template<typename U> using B = S; +template<typename U> using C = T<U>; +template<typename U, typename V> using D = typename T<U>::template A<V>; diff --git a/test/PCH/cxx-alias-decl.h b/test/PCH/cxx-alias-decl.h new file mode 100644 index 000000000000..26bc716b08a6 --- /dev/null +++ b/test/PCH/cxx-alias-decl.h @@ -0,0 +1,11 @@ +// Header for PCH test cxx-alias-decl.cpp + +struct S {}; +template<typename U> struct T { + template<typename V> using A = T<V>; +}; + +using A = int; +template<typename U> using B = S; +template<typename U> using C = T<U>; +template<typename U, typename V> using D = typename T<U>::template A<V>; diff --git a/test/PCH/cxx-for-range.cpp b/test/PCH/cxx-for-range.cpp index 5854917da5c7..46e217c574cb 100644 --- a/test/PCH/cxx-for-range.cpp +++ b/test/PCH/cxx-for-range.cpp @@ -1,9 +1,9 @@ // Test this without pch. -// RUN: %clang_cc1 -std=c++0x -include %S/cxx-for-range.h -fsyntax-only -emit-llvm -o - %s +// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-for-range.h -fsyntax-only -emit-llvm -o - %s // Test with pch. -// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %S/cxx-for-range.h -// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s +// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-for-range.h +// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s void h() { f(); diff --git a/test/PCH/cxx-member-init.cpp b/test/PCH/cxx-member-init.cpp new file mode 100644 index 000000000000..70392a283261 --- /dev/null +++ b/test/PCH/cxx-member-init.cpp @@ -0,0 +1,22 @@ +// Test this without pch. +// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -DSOURCE -fsyntax-only -emit-llvm -o - %s + +// Test with pch. +// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -emit-pch -o %t %s +// RUN: %clang_cc1 -x c++ -std=c++0x -DHEADER -include-pch %t -fsyntax-only -emit-llvm -o - %s + +#ifdef HEADER +int n; +struct S { + int *p = &m; + int &m = n; + S *that = this; +}; +#endif + +#ifdef SOURCE +S s; +#elif HEADER +#undef HEADER +#define SOURCE +#endif diff --git a/test/PCH/cxx-reference.cpp b/test/PCH/cxx-reference.cpp index 90d00d777c44..2dfbcdc1382b 100644 --- a/test/PCH/cxx-reference.cpp +++ b/test/PCH/cxx-reference.cpp @@ -1,6 +1,6 @@ // Test this without pch. -// RUN: %clang_cc1 -std=c++0x -include %S/cxx-reference.h -fsyntax-only -emit-llvm -o - %s +// RUN: %clang_cc1 -x c++ -std=c++0x -include %S/cxx-reference.h -fsyntax-only -emit-llvm -o - %s // Test with pch. -// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %S/cxx-reference.h -// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s +// RUN: %clang_cc1 -x c++ -std=c++0x -emit-pch -o %t %S/cxx-reference.h +// RUN: %clang_cc1 -x c++ -std=c++0x -include-pch %t -fsyntax-only -emit-llvm -o - %s diff --git a/test/PCH/cxx-static_assert.cpp b/test/PCH/cxx-static_assert.cpp index 34409218ecd4..464da405c3e2 100644 --- a/test/PCH/cxx-static_assert.cpp +++ b/test/PCH/cxx-static_assert.cpp @@ -1,11 +1,20 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/cxx-static_assert.h -verify -std=c++0x %s +// RUN: %clang_cc1 -include %s -verify -std=c++0x %s // Test with pch. -// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %S/cxx-static_assert.h +// RUN: %clang_cc1 -std=c++0x -emit-pch -o %t %s // RUN: %clang_cc1 -include-pch %t -verify -std=c++0x %s -// expected-error {{static_assert failed "N is not 2!"}} +#ifndef HEADER +#define HEADER + +template<int N> struct T { + static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}} +}; + +#else T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}} T<2> t2; + +#endif diff --git a/test/PCH/cxx-static_assert.h b/test/PCH/cxx-static_assert.h deleted file mode 100644 index ba41ab8feddb..000000000000 --- a/test/PCH/cxx-static_assert.h +++ /dev/null @@ -1,9 +0,0 @@ -// Header for PCH test cxx-static_assert.cpp - - - - - -template<int N> struct T { - static_assert(N == 2, "N is not 2!"); -}; diff --git a/test/PCH/cxx0x-default-delete.cpp b/test/PCH/cxx0x-default-delete.cpp new file mode 100644 index 000000000000..753ac4736c70 --- /dev/null +++ b/test/PCH/cxx0x-default-delete.cpp @@ -0,0 +1,23 @@ +// Without PCH +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify -include %s %s +// With PCH +// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %s +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify -include-pch %t %s + +#ifndef PASS1 +#define PASS1 + +struct foo { + foo() = default; + void bar() = delete; // expected-note{{deleted here}} +}; + +#else + +foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}} +foo f; +void fn() { + f.bar(); // expected-error{{deleted function}} +} + +#endif diff --git a/test/PCH/cxx0x-delegating-ctors.cpp b/test/PCH/cxx0x-delegating-ctors.cpp new file mode 100644 index 000000000000..15311f852944 --- /dev/null +++ b/test/PCH/cxx0x-delegating-ctors.cpp @@ -0,0 +1,20 @@ +// Test this without pch. +// RUN: %clang_cc1 -include %s -std=c++0x -fsyntax-only -verify %s + +// Test with pch. +// RUN: %clang_cc1 -x c++-header -std=c++0x -emit-pch -o %t %s +// RUN: %clang_cc1 -std=c++0x -include-pch %t -fsyntax-only -verify %s + +#ifndef PASS1 +#define PASS1 +struct foo { + foo(int) : foo() { } // expected-note{{it delegates to}} + foo(); + foo(bool) : foo('c') { } // expected-note{{it delegates to}} + foo(char) : foo(true) { } // expected-error{{creates a delegation cycle}} \ + // expected-note{{which delegates to}} +}; +#else +foo::foo() : foo(1) { } // expected-error{{creates a delegation cycle}} \ + // expected-note{{which delegates to}} +#endif diff --git a/test/PCH/modified-header-error.c b/test/PCH/modified-header-error.c new file mode 100644 index 000000000000..6335fb1b4539 --- /dev/null +++ b/test/PCH/modified-header-error.c @@ -0,0 +1,11 @@ +// RUN: mkdir -p %t.dir +// RUN: echo '#include "header2.h"' > %t.dir/header1.h +// RUN: echo > %t.dir/header2.h +// 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 + +#include "header2.h" + +// CHECK: fatal error: file {{.*}} has been modified since the precompiled header was built diff --git a/test/PCH/objc_methods.h b/test/PCH/objc_methods.h index 4c6b1e1ccec0..bd775354349f 100644 --- a/test/PCH/objc_methods.h +++ b/test/PCH/objc_methods.h @@ -2,7 +2,7 @@ @interface TestPCH + alloc; -- (void)instMethod; +- (id)init; @end @class TestForwardClassDecl; diff --git a/test/PCH/objc_methods.m b/test/PCH/objc_methods.m index e90a463dce6b..3311813c98df 100644 --- a/test/PCH/objc_methods.m +++ b/test/PCH/objc_methods.m @@ -12,5 +12,5 @@ void func() { // AliasForTestPCH *zz; xx = [TestPCH alloc]; - [xx instMethod]; + [xx init]; } diff --git a/test/PCH/objcxx-ivar-class.mm b/test/PCH/objcxx-ivar-class.mm index 89d3e087f90f..821495747d46 100644 --- a/test/PCH/objcxx-ivar-class.mm +++ b/test/PCH/objcxx-ivar-class.mm @@ -6,7 +6,7 @@ // RUN: %clang_cc1 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s // CHECK: [C position] -// CHECK: call void @_ZN1SC1ERKS_ +// CHECK: call {{.*}} @_ZN1SC1ERKS_ // CHECK: [C setPosition:] // CHECK: call %struct.S* @_ZN1SaSERKS_ |