diff options
author | dim <dim@FreeBSD.org> | 2012-05-03 16:53:59 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-05-03 16:53:59 +0000 |
commit | 822bde9df508e0b9afac5e581b0d6ab403417a28 (patch) | |
tree | 2e51705e103e92c7be1b21e8bd8ffd5b5d0e4d52 /test | |
parent | 50b73317314e889cf39c7b1d6cbf419fa7502f22 (diff) | |
download | FreeBSD-src-822bde9df508e0b9afac5e581b0d6ab403417a28.zip FreeBSD-src-822bde9df508e0b9afac5e581b0d6ab403417a28.tar.gz |
Vendor import of clang release_31 branch r155985:
http://llvm.org/svn/llvm-project/cfe/branches/release_31@155985
Diffstat (limited to 'test')
81 files changed, 1178 insertions, 111 deletions
diff --git a/test/Analysis/objc-bool.m b/test/Analysis/objc-bool.m index 631cd2d..f95736a 100644 --- a/test/Analysis/objc-bool.m +++ b/test/Analysis/objc-bool.m @@ -1,4 +1,4 @@ -// RUN: %clang --analyze %s -o %t -verify +// RUN: %clang --analyze %s -o %t -Xclang -verify // Test handling of ObjC bool literals. diff --git a/test/Analysis/redefined_system.c b/test/Analysis/redefined_system.c index 3f585c4..3c08b5e 100644 --- a/test/Analysis/redefined_system.c +++ b/test/Analysis/redefined_system.c @@ -12,6 +12,6 @@ char strdup(); char atoi(); int foo () { - return memmove() + malloc() + system + stdin() + memccpy() + free() + strdup() + atoi(); + return memmove() + malloc() + system() + stdin() + memccpy() + free() + strdup() + atoi(); } diff --git a/test/Analysis/self-init.m b/test/Analysis/self-init.m index 3db42e9..d515173 100644 --- a/test/Analysis/self-init.m +++ b/test/Analysis/self-init.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit %s -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties %s -verify @class NSZone, NSCoder; @protocol NSObject- (id)self; @@ -48,9 +48,7 @@ void log(void *obj); extern void *somePtr; @class MyObj; -static id _commonInit(MyObj *self) { - return self; -} +extern id _commonInit(MyObj *self); @interface MyObj : NSObject { id myivar; @@ -59,6 +57,7 @@ static id _commonInit(MyObj *self) { -(id)_init; -(id)initWithSomething:(int)x; -(void)doSomething; ++(id)commonInitMember:(id)s; @end @interface MyProxyObj : NSProxy {} @@ -90,6 +89,14 @@ static id _commonInit(MyObj *self) { return self; } +-(id)init4_w { + [super init]; + if (self) { + log(&self); + } + return self; // expected-warning {{Returning 'self' while it is not set to the result of '[(super or self) init...]'}} +} + - (id)initWithSomething:(int)x { if ((self = [super init])) myint = x; @@ -157,6 +164,12 @@ static id _commonInit(MyObj *self) { return self; } +-(id)init14_w { + [super init]; + self = _commonInit(self); + return self; // expected-warning {{Returning 'self' while it is not set to the result of '[(super or self) init...]'}} +} + -(id)init15 { if (!(self = [super init])) return 0; @@ -176,6 +189,28 @@ static id _commonInit(MyObj *self) { return 0; } +-(id)init18 { + self = [super init]; + self = _commonInit(self); + return self; +} + ++(id)commonInitMember:(id)s { + return s; +} + +-(id)init19 { + self = [super init]; + self = [MyObj commonInitMember:self]; + return self; +} + +-(id)init19_w { + [super init]; + self = [MyObj commonInitMember:self]; + return self; // expected-warning {{Returning 'self'}} +} + -(void)doSomething {} @end @@ -201,3 +236,21 @@ static id _commonInit(MyObj *self) { } @end +// Test radar:11235991 - passing self to a call to super. +@protocol MyDelegate +@end +@interface Object : NSObject +- (id) initWithObject: (id)i; +@end +@interface Derived: Object <MyDelegate> +- (id) initWithInt: (int)t; +@property (nonatomic, retain, readwrite) Object *size; +@end +@implementation Derived +- (id) initWithInt: (int)t { + if ((self = [super initWithObject:self])) { + _size = [[Object alloc] init]; + } + return self; +} +@end diff --git a/test/CXX/class/class.mem/p2.cpp b/test/CXX/class/class.mem/p2.cpp index 09040d8..0a823f4 100644 --- a/test/CXX/class/class.mem/p2.cpp +++ b/test/CXX/class/class.mem/p2.cpp @@ -29,3 +29,30 @@ namespace test2 { A<int> x; }; } + +namespace test3 { + struct A { + struct B { + void f() throw(A); + void g() throw(B); + }; + + void f() throw(A); + void g() throw(B); + }; + + template<typename T> + struct A2 { + struct B { + void f1() throw(A2); + void f2() throw(A2<T>); + void g() throw(B); + }; + + void f1() throw(A2); + void f2() throw(A2<T>); + void g() throw(B); + }; + + template struct A2<int>; +} diff --git a/test/CXX/except/except.spec/p1.cpp b/test/CXX/except/except.spec/p1.cpp index c68ec56..e184ec4 100644 --- a/test/CXX/except/except.spec/p1.cpp +++ b/test/CXX/except/except.spec/p1.cpp @@ -65,7 +65,7 @@ namespace noexcept_unevaluated { } template<typename T> - void g(T x) noexcept((sizeof(T) == sizeof(int)) || f(x)) { } + void g(T x) noexcept((sizeof(T) == sizeof(int)) || noexcept(f(x))) { } void h() { g(1); @@ -77,5 +77,5 @@ namespace PR11084 { static int f() noexcept(1/X) { return 10; } // expected-error{{argument to noexcept specifier must be a constant expression}} expected-note{{division by zero}} }; - void g() { A<0>::f(); } // expected-note{{in instantiation of template class 'PR11084::A<0>' requested here}} + void g() { A<0>::f(); } // expected-note{{in instantiation of exception specification for 'f' requested here}} } diff --git a/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp b/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp new file mode 100644 index 0000000..ad4f406 --- /dev/null +++ b/test/CXX/expr/expr.prim/expr.prim.general/p3-0x.cpp @@ -0,0 +1,100 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify + +struct A { + int &f(int*); + float &f(int*) const noexcept; + + int *ptr; + auto g1() noexcept(noexcept(f(ptr))) -> decltype(f(this->ptr)); + auto g2() const noexcept(noexcept(f((*this).ptr))) -> decltype(f(ptr)); +}; + +void testA(A &a) { + int &ir = a.g1(); + float &fr = a.g2(); + static_assert(!noexcept(a.g1()), "exception-specification failure"); + static_assert(noexcept(a.g2()), "exception-specification failure"); +} + +struct B { + char g(); + template<class T> auto f(T t) -> decltype(t + g()) + { return t + g(); } +}; + +template auto B::f(int t) -> decltype(t + g()); + +template<typename T> +struct C { + int &f(T*); + float &f(T*) const noexcept; + + T* ptr; + auto g1() noexcept(noexcept(f(ptr))) -> decltype(f((*this).ptr)); + auto g2() const noexcept(noexcept(f(((this))->ptr))) -> decltype(f(ptr)); +}; + +void test_C(C<int> ci) { + int *p = 0; + int &ir = ci.g1(); + float &fr = ci.g2(); + static_assert(!noexcept(ci.g1()), "exception-specification failure"); + static_assert(noexcept(ci.g2()), "exception-specification failure"); +} + +namespace PR10036 { + template <class I> + void + iter_swap(I x, I y) noexcept; + + template <class T> + class A + { + T t_; + public: + void swap(A& a) noexcept(noexcept(iter_swap(&t_, &a.t_))); + }; + + void test() { + A<int> i, j; + i.swap(j); + } +} + +namespace Static { + struct X1 { + int m; + static auto f() -> decltype(m); // expected-error{{'this' cannot be implicitly used in a static member function declaration}} + static auto g() -> decltype(this->m); // expected-error{{'this' cannot be used in a static member function declaration}} + + static int h(); + + static int i() noexcept(noexcept(m + 2)); // expected-error{{'this' cannot be implicitly used in a static member function declaration}} + }; + + auto X1::h() -> decltype(m) { return 0; } // expected-error{{'this' cannot be implicitly used in a static member function declaration}} + + template<typename T> + struct X2 { + int m; + + T f(T*); + static T f(int); + + auto g(T x) -> decltype(f(x)) { return 0; } + }; + + void test_X2() { + X2<int>().g(0); + } +} + +namespace PR12564 { + struct Base { + void bar(Base&) {} + }; + + struct Derived : Base { + void foo(Derived& d) noexcept(noexcept(d.bar(d))) {} + }; +} diff --git a/test/CXX/special/class.inhctor/elsewhere.cpp b/test/CXX/special/class.inhctor/elsewhere.cpp index 66afa17..09fd3d5 100644 --- a/test/CXX/special/class.inhctor/elsewhere.cpp +++ b/test/CXX/special/class.inhctor/elsewhere.cpp @@ -9,15 +9,15 @@ struct B1 { B1(int); }; -using B1::B1; // expected-error {{using declaration can not refer to class member}} +using B1::B1; // expected-error {{using declaration can not refer to class member}} expected-error {{not supported}} // C++0x [namespace.udecl]p10: // A using-declaration is a declaration and can therefore be used repeatedly // where (and only where) multiple declarations are allowed. struct I1 : B1 { - using B1::B1; // expected-note {{previous using declaration}} - using B1::B1; // expected-error {{redeclaration of using decl}} + using B1::B1; // expected-note {{previous using declaration}} expected-error {{not supported}} + using B1::B1; // expected-error {{redeclaration of using decl}} expected-error {{not supported}} }; // C++0x [namespace.udecl]p3: @@ -27,31 +27,31 @@ struct I1 : B1 { // shall name a direct base class of the class being defined. struct D1 : I1 { - using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', can not inherit constructors}} + using B1::B1; // expected-error {{'B1' is not a direct base of 'D1', can not inherit constructors}} expected-error {{not supported}} }; template<typename T> struct A {}; template<typename T> struct B : A<bool>, A<char> { - using A<T>::A; // expected-error {{'A<double>::', which is not a base class of 'B<double>'}} + using A<T>::A; // expected-error {{'A<double>::', which is not a base class of 'B<double>'}} expected-error {{not supported}} }; B<bool> bb; B<char> bc; B<double> bd; // expected-note {{here}} template<typename T> struct C : A<T> { - using A<bool>::A; // expected-error {{'A<bool>::', which is not a base class of 'C<char>'}} + using A<bool>::A; // expected-error {{'A<bool>::', which is not a base class of 'C<char>'}} expected-error {{not supported}} }; C<bool> cb; C<char> cc; // expected-note {{here}} template<typename T> struct D : A<T> {}; template<typename T> struct E : D<T> { - using A<bool>::A; // expected-error {{'A<bool>' is not a direct base of 'E<bool>', can not inherit}} + using A<bool>::A; // expected-error {{'A<bool>' is not a direct base of 'E<bool>', can not inherit}} expected-error {{not supported}} }; E<bool> eb; // expected-note {{here}} template<typename T> struct F : D<bool> { - using A<T>::A; // expected-error {{'A<bool>' is not a direct base of 'F<bool>'}} + using A<T>::A; // expected-error {{'A<bool>' is not a direct base of 'F<bool>'}} expected-error {{not supported}} }; F<bool> fb; // expected-note {{here}} diff --git a/test/CXX/special/class.inhctor/p3.cpp b/test/CXX/special/class.inhctor/p3.cpp index f71ab16..d7093fb 100644 --- a/test/CXX/special/class.inhctor/p3.cpp +++ b/test/CXX/special/class.inhctor/p3.cpp @@ -5,7 +5,7 @@ struct B1 { B1(int, int); }; struct D1 : B1 { - using B1::B1; + using B1::B1; // expected-error {{not supported}} }; D1 d1a(1), d1b(1, 1); @@ -15,7 +15,7 @@ struct B2 { explicit B2(int, int = 0, int = 0); }; struct D2 : B2 { // expected-note 2 {{candidate constructor}} - using B2::B2; + using B2::B2; // expected-error {{not supported}} }; D2 d2a(1), d2b(1, 1), d2c(1, 1, 1); @@ -25,18 +25,18 @@ struct B3 { B3(void*); // expected-note {{inherited from here}} }; struct D3 : B3 { // expected-note 2 {{candidate constructor}} - using B3::B3; // expected-note {{candidate constructor (inherited)}} + using B3::B3; // expected-note {{candidate constructor (inherited)}} expected-error {{not supported}} }; D3 fd3() { return 1; } // expected-error {{no viable conversion}} template<typename T> struct T1 : B1 { - using B1::B1; + using B1::B1; // expected-error {{not supported}} }; template<typename T> struct T2 : T1<T> { - using T1<int>::T1; + using T1<int>::T1; // expected-error {{not supported}} }; template<typename T> struct T3 : T1<int> { - using T1<T>::T1; + using T1<T>::T1; // expected-error {{not supported}} }; struct U { friend T1<int>::T1(int); diff --git a/test/CXX/special/class.inhctor/p7.cpp b/test/CXX/special/class.inhctor/p7.cpp index 9ae160f..bfaa3ac 100644 --- a/test/CXX/special/class.inhctor/p7.cpp +++ b/test/CXX/special/class.inhctor/p7.cpp @@ -8,12 +8,12 @@ struct B2 { B2(int); // expected-note {{conflicting constructor}} }; struct D1 : B1, B2 { - using B1::B1; // expected-note {{inherited here}} - using B2::B2; // expected-error {{already inherited constructor with the same signature}} + using B1::B1; // expected-note {{inherited here}} expected-error {{not supported}} + using B2::B2; // expected-error {{already inherited constructor with the same signature}} expected-error {{not supported}} }; struct D2 : B1, B2 { - using B1::B1; - using B2::B2; + using B1::B1; // expected-error {{not supported}} + using B2::B2; // expected-error {{not supported}} D2(int); }; @@ -22,8 +22,8 @@ template<typename T> struct B3 { }; template<typename T> struct B4 : B3<T>, B1 { B4(); - using B3<T>::B3; // expected-note {{inherited here}} - using B1::B1; // expected-error {{already inherited}} + using B3<T>::B3; // expected-note {{inherited here}} expected-error {{not supported}} + using B1::B1; // expected-error {{already inherited}} expected-error {{not supported}} }; B4<char> b4c; B4<int> b4i; // expected-note {{here}} diff --git a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp index 6955219..726e222 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/p5.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/p5.cpp @@ -164,7 +164,7 @@ template<typename T, typename... Types> // FIXME: this should test that the diagnostic reads "type contains..." struct alignas(Types) TestUnexpandedDecls : T{ // expected-error{{expression contains unexpanded parameter pack 'Types'}} void member_function(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} - void member_function () throw(Types); // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} + void member_function () throw(Types); // expected-error{{exception type contains unexpanded parameter pack 'Types'}} operator Types() const; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} Types data_member; // expected-error{{data member type contains unexpanded parameter pack 'Types'}} static Types static_data_member; // expected-error{{declaration type contains unexpanded parameter pack 'Types'}} diff --git a/test/CodeCompletion/preamble.c b/test/CodeCompletion/preamble.c new file mode 100644 index 0000000..f322e09 --- /dev/null +++ b/test/CodeCompletion/preamble.c @@ -0,0 +1,7 @@ +#include "some_struct.h" +void foo() { + struct X x; + x. + +// RUN: env CINDEXTEST_EDITING=1 c-index-test -code-completion-at=%s:4:5 -Xclang -code-completion-patterns %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: FieldDecl:{ResultType int}{TypedText m} (35) (parent: StructDecl 'X') diff --git a/test/CodeCompletion/some_struct.h b/test/CodeCompletion/some_struct.h new file mode 100644 index 0000000..63aa2a3 --- /dev/null +++ b/test/CodeCompletion/some_struct.h @@ -0,0 +1 @@ +struct X { int m; }; diff --git a/test/CodeGen/arm-homogenous.c b/test/CodeGen/arm-homogenous.c new file mode 100644 index 0000000..eb3d5a6 --- /dev/null +++ b/test/CodeGen/arm-homogenous.c @@ -0,0 +1,160 @@ +// RUN: %clang_cc1 -triple armv7---eabi -target-abi aapcs -mfloat-abi hard -emit-llvm %s -o - | FileCheck %s + +typedef long long int64_t; +typedef unsigned int uint32_t; + +/* This is not a homogenous aggregate - fundamental types are different */ +typedef union { + float f[4]; + uint32_t i[4]; +} union_with_first_floats; +union_with_first_floats g_u_f; + +extern void takes_union_with_first_floats(union_with_first_floats a); +extern union_with_first_floats returns_union_with_first_floats(void); + +void test_union_with_first_floats(void) { + takes_union_with_first_floats(g_u_f); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_first_floats([4 x i32]) + +void test_return_union_with_first_floats(void) { + g_u_f = returns_union_with_first_floats(); +} +// CHECK: declare arm_aapcs_vfpcc void @returns_union_with_first_floats(%union.union_with_first_floats* sret) + +/* This is not a homogenous aggregate - fundamental types are different */ +typedef union { + uint32_t i[4]; + float f[4]; +} union_with_non_first_floats; +union_with_non_first_floats g_u_nf_f; + +extern void takes_union_with_non_first_floats(union_with_non_first_floats a); +extern union_with_non_first_floats returns_union_with_non_first_floats(void); + +void test_union_with_non_first_floats(void) { + takes_union_with_non_first_floats(g_u_nf_f); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_non_first_floats([4 x i32]) + +void test_return_union_with_non_first_floats(void) { + g_u_nf_f = returns_union_with_non_first_floats(); +} +// CHECK: declare arm_aapcs_vfpcc void @returns_union_with_non_first_floats(%union.union_with_non_first_floats* sret) + +/* This is not a homogenous aggregate - fundamental types are different */ +typedef struct { + float a; + union_with_first_floats b; +} struct_with_union_with_first_floats; +struct_with_union_with_first_floats g_s_f; + +extern void takes_struct_with_union_with_first_floats(struct_with_union_with_first_floats a); +extern struct_with_union_with_first_floats returns_struct_with_union_with_first_floats(void); + +void test_struct_with_union_with_first_floats(void) { + takes_struct_with_union_with_first_floats(g_s_f); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_first_floats([5 x i32]) + +void test_return_struct_with_union_with_first_floats(void) { + g_s_f = returns_struct_with_union_with_first_floats(); +} +// CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_first_floats(%struct.struct_with_union_with_first_floats* sret) + +/* This is not a homogenous aggregate - fundamental types are different */ +typedef struct { + float a; + union_with_non_first_floats b; +} struct_with_union_with_non_first_floats; +struct_with_union_with_non_first_floats g_s_nf_f; + +extern void takes_struct_with_union_with_non_first_floats(struct_with_union_with_non_first_floats a); +extern struct_with_union_with_non_first_floats returns_struct_with_union_with_non_first_floats(void); + +void test_struct_with_union_with_non_first_floats(void) { + takes_struct_with_union_with_non_first_floats(g_s_nf_f); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_union_with_non_first_floats([5 x i32]) + +void test_return_struct_with_union_with_non_first_floats(void) { + g_s_nf_f = returns_struct_with_union_with_non_first_floats(); +} +// CHECK: declare arm_aapcs_vfpcc void @returns_struct_with_union_with_non_first_floats(%struct.struct_with_union_with_non_first_floats* sret) + +/* Plain array is not a homogenous aggregate */ +extern void takes_array_of_floats(float a[4]); +void test_array_of_floats(void) { + float a[4] = {1.0, 2.0, 3.0, 4.0}; + takes_array_of_floats(a); +} +// CHECK: declare arm_aapcs_vfpcc void @takes_array_of_floats(float*) + +/* Struct-type homogenous aggregate */ +typedef struct { + float x, y, z, w; +} struct_with_fundamental_elems; +struct_with_fundamental_elems g_s; + +extern void takes_struct_with_fundamental_elems(struct_with_fundamental_elems a); +extern struct_with_fundamental_elems returns_struct_with_fundamental_elems(void); + +void test_struct_with_fundamental_elems(void) { + takes_struct_with_fundamental_elems(g_s); +// CHECK: call arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(float {{.*}}, float {{.*}}, float{{.*}}, float {{.*}}) +} +// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_fundamental_elems(float, float, float, float) + +void test_return_struct_with_fundamental_elems(void) { + g_s = returns_struct_with_fundamental_elems(); +// CHECK: call arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems() +} +// CHECK: declare arm_aapcs_vfpcc %struct.struct_with_fundamental_elems @returns_struct_with_fundamental_elems() + +/* Array-type homogenous aggregate */ +typedef struct { + float xyzw[4]; +} struct_with_array; +struct_with_array g_s_a; + +extern void takes_struct_with_array(struct_with_array a); +extern struct_with_array returns_struct_with_array(void); + +void test_struct_with_array(void) { + takes_struct_with_array(g_s_a); +// CHECK: call arm_aapcs_vfpcc void @takes_struct_with_array(float {{.*}}, float {{.*}}, float {{.*}}, float {{.*}}) +} +// CHECK: declare arm_aapcs_vfpcc void @takes_struct_with_array(float, float, float, float) + +void test_return_struct_with_array(void) { + g_s_a = returns_struct_with_array(); +// CHECK: call arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array() +} +// CHECK: declare arm_aapcs_vfpcc %struct.struct_with_array @returns_struct_with_array() + +/* This union is a homogenous aggregate. Check that it's passed properly */ +typedef union { + struct_with_fundamental_elems xyzw; + float a[3]; +} union_with_struct_with_fundamental_elems; +union_with_struct_with_fundamental_elems g_u_s_fe; + +extern void takes_union_with_struct_with_fundamental_elems(union_with_struct_with_fundamental_elems a); +extern union_with_struct_with_fundamental_elems returns_union_with_struct_with_fundamental_elems(void); + +void test_union_with_struct_with_fundamental_elems(void) { + takes_union_with_struct_with_fundamental_elems(g_u_s_fe); +// CHECK: call arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(float {{.*}}, float {{.*}}, float {{.*}}, float {{.*}}) +} +// CHECK: declare arm_aapcs_vfpcc void @takes_union_with_struct_with_fundamental_elems(float, float, float, float) + +void test_return_union_with_struct_with_fundamental_elems(void) { + g_u_s_fe = returns_union_with_struct_with_fundamental_elems(); +// CHECK: call arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems() +} +// CHECK: declare arm_aapcs_vfpcc %union.union_with_struct_with_fundamental_elems @returns_union_with_struct_with_fundamental_elems() + +// FIXME: Tests necessary: +// - Vectors +// - C++ stuff
\ No newline at end of file diff --git a/test/CodeGen/avx-shuffle-builtins.c b/test/CodeGen/avx-shuffle-builtins.c index 538ae50..d071f82 100644 --- a/test/CodeGen/avx-shuffle-builtins.c +++ b/test/CodeGen/avx-shuffle-builtins.c @@ -48,18 +48,18 @@ __m256 test_mm256_permute_ps(__m256 a) { __m256d test_mm256_permute2f128_pd(__m256d a, __m256d b) { // Check if the mask is correct - // CHECK: shufflevector{{.*}}<i32 2, i32 3, i32 6, i32 7> + // CHECK: @llvm.x86.avx.vperm2f128.pd.256 return _mm256_permute2f128_pd(a, b, 0x31); } __m256 test_mm256_permute2f128_ps(__m256 a, __m256 b) { // Check if the mask is correct - // CHECK: shufflevector{{.*}}<i32 12, i32 13, i32 14, i32 15, i32 4, i32 5, i32 6, i32 7> + // CHECK: @llvm.x86.avx.vperm2f128.ps.256 return _mm256_permute2f128_ps(a, b, 0x13); } __m256i test_mm256_permute2f128_si256(__m256i a, __m256i b) { // Check if the mask is correct - // CHECK: shufflevector{{.*}}<i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11> + // CHECK: @llvm.x86.avx.vperm2f128.si.256 return _mm256_permute2f128_si256(a, b, 0x20); } diff --git a/test/CodeGen/avx2-builtins.c b/test/CodeGen/avx2-builtins.c index a5ddc8e..7d166b5 100644 --- a/test/CodeGen/avx2-builtins.c +++ b/test/CodeGen/avx2-builtins.c @@ -662,7 +662,7 @@ __m256i test_mm256_permutevar8x32_epi32(__m256i a, __m256i b) { } __m256d test_mm256_permute4x64_pd(__m256d a) { - // CHECK: @llvm.x86.avx2.permpd + // CHECK: shufflevector{{.*}}<i32 1, i32 2, i32 1, i32 0> return _mm256_permute4x64_pd(a, 25); } @@ -672,12 +672,12 @@ __m256 test_mm256_permutevar8x32_ps(__m256 a, __m256 b) { } __m256i test_mm256_permute4x64_epi64(__m256i a) { - // CHECK: @llvm.x86.avx2.permq + // CHECK: shufflevector{{.*}}<i32 3, i32 0, i32 2, i32 0> return _mm256_permute4x64_epi64(a, 35); } __m256i test_mm256_permute2x128_si256(__m256i a, __m256i b) { - // CHECK: shufflevector{{.*}}<i32 2, i32 3, i32 6, i32 7> + // CHECK: @llvm.x86.avx2.vperm2i128 return _mm256_permute2x128_si256(a, b, 0x31); } diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c index 30138d6..acb5554 100644 --- a/test/CodeGen/builtins-x86.c +++ b/test/CodeGen/builtins-x86.c @@ -414,6 +414,9 @@ void f0() { tmp_V4i = __builtin_ia32_cvttpd2dq256(tmp_V4d); tmp_V4i = __builtin_ia32_cvtpd2dq256(tmp_V4d); tmp_V8i = __builtin_ia32_cvttps2dq256(tmp_V8f); + tmp_V4d = __builtin_ia32_vperm2f128_pd256(tmp_V4d, tmp_V4d, 0x7); + tmp_V8f = __builtin_ia32_vperm2f128_ps256(tmp_V8f, tmp_V8f, 0x7); + tmp_V8i = __builtin_ia32_vperm2f128_si256(tmp_V8i, tmp_V8i, 0x7); tmp_V4d = __builtin_ia32_vinsertf128_pd256(tmp_V4d, tmp_V2d, 0x7); tmp_V8f = __builtin_ia32_vinsertf128_ps256(tmp_V8f, tmp_V4f, 0x7); tmp_V8i = __builtin_ia32_vinsertf128_si256(tmp_V8i, tmp_V4i, 0x7); diff --git a/test/CodeGen/may-alias.c b/test/CodeGen/may-alias.c index 6171be7..b73ee15 100644 --- a/test/CodeGen/may-alias.c +++ b/test/CodeGen/may-alias.c @@ -26,5 +26,5 @@ void test1(struct Test1MA *p1, struct Test1 *p2) { // CHECK: !0 = metadata !{metadata !"any pointer", metadata !1} // CHECK: !1 = metadata !{metadata !"omnipotent char", metadata !2} -// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA", null} +// CHECK: !2 = metadata !{metadata !"Simple C/C++ TBAA"} // CHECK: !3 = metadata !{metadata !"int", metadata !1} diff --git a/test/CodeGen/packed-nest-unpacked.c b/test/CodeGen/packed-nest-unpacked.c index af1508a..0ccc0c4 100644 --- a/test/CodeGen/packed-nest-unpacked.c +++ b/test/CodeGen/packed-nest-unpacked.c @@ -1,11 +1,12 @@ // RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.7.2 -emit-llvm -o - | FileCheck %s -// <rdar://problem/10463337> struct X { int x[6]; }; struct Y { char x[13]; struct X y; } __attribute((packed)); struct Y g; void f(struct X); +struct X foo(void); +// <rdar://problem/10463337> struct X test1() { // CHECK: @test1 // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false) @@ -24,8 +25,23 @@ void test3(struct X a) { g.y = a; } +// <rdar://problem/10530444> void test4() { // CHECK: @test4 // FIXME: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i64 24, i32 1, i1 false) f(g.y); } + +// PR12395 +int test5() { + // CHECK: @test5 + // CHECK: load i32* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1, i32 0, i64 0), align 1 + return g.y.x[0]; +} + +// <rdar://problem/11220251> +void test6() { + // CHECK: @test6 + // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* %{{.*}}, i64 24, i32 1, i1 false) + g.y = foo(); +} diff --git a/test/CodeGen/tbaa-for-vptr.cpp b/test/CodeGen/tbaa-for-vptr.cpp index f4885f80..5ce6bf3 100644 --- a/test/CodeGen/tbaa-for-vptr.cpp +++ b/test/CodeGen/tbaa-for-vptr.cpp @@ -16,4 +16,4 @@ void CallFoo(A *a) { // CHECK: %{{.*}} = load {{.*}} !tbaa !0 // CHECK: store {{.*}} !tbaa !0 // CHECK: !0 = metadata !{metadata !"vtable pointer", metadata !1} -// CHECK: !1 = metadata !{metadata !"Simple C/C++ TBAA", null} +// CHECK: !1 = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/test/CodeGenCXX/block-byref-cxx-objc.cpp b/test/CodeGenCXX/block-byref-cxx-objc.cpp index 135e0c7..30f1f07 100644 --- a/test/CodeGenCXX/block-byref-cxx-objc.cpp +++ b/test/CodeGenCXX/block-byref-cxx-objc.cpp @@ -23,3 +23,13 @@ int main() // CHECK: call void @_Block_object_assign // CHECK: define internal void @__destroy_helper_block_ // CHECK: call void @_Block_object_dispose + +// rdar://problem/11135650 +namespace test1 { + struct A { int x; A(); ~A(); }; + + void test() { + return; + __block A a; + } +} diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp index c745dee..62a345a 100644 --- a/test/CodeGenCXX/const-init-cxx11.cpp +++ b/test/CodeGenCXX/const-init-cxx11.cpp @@ -92,6 +92,9 @@ namespace Array { // CHECK: @_ZN5Array1cE = constant [6 x [4 x i8]] [{{.*}} c"foo\00", [4 x i8] c"a\00\00\00", [4 x i8] c"bar\00", [4 x i8] c"xyz\00", [4 x i8] c"b\00\00\00", [4 x i8] c"123\00"] extern constexpr char c[6][4] = { "foo", "a", { "bar" }, { 'x', 'y', 'z' }, { "b" }, '1', '2', '3' }; + // CHECK: @_ZN5Array2ucE = constant [4 x i8] c"foo\00" + extern constexpr unsigned char uc[] = { "foo" }; + struct C { constexpr C() : n(5) {} int n, m = 3 * n + 1; }; // CHECK: @_ZN5Array5ctorsE = constant [3 x {{.*}}] [{{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }, {{.*}} { i32 5, i32 16 }] extern const C ctors[3]; diff --git a/test/CodeGenCXX/cxx11-exception-spec.cpp b/test/CodeGenCXX/cxx11-exception-spec.cpp new file mode 100644 index 0000000..194b80c --- /dev/null +++ b/test/CodeGenCXX/cxx11-exception-spec.cpp @@ -0,0 +1,120 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -verify -fexceptions -fcxx-exceptions -triple x86_64-linux-gnu | FileCheck %s + +void h(); + +template<typename T> void f() noexcept(sizeof(T) == 4) { h(); } +template<typename T> void g() noexcept(sizeof(T) == 4); + +template<typename T> struct S { + static void f() noexcept(sizeof(T) == 4) { h(); } + static void g() noexcept(sizeof(T) == 4); +}; + +// CHECK: define {{.*}} @_Z1fIsEvv() { +template<> void f<short>() { h(); } +// CHECK: define {{.*}} @_Z1fIA2_sEvv() nounwind { +template<> void f<short[2]>() noexcept { h(); } + +// CHECK: define {{.*}} @_ZN1SIsE1fEv() +// CHECK-NOT: nounwind +template<> void S<short>::f() { h(); } +// CHECK: define {{.*}} @_ZN1SIA2_sE1fEv() nounwind +template<> void S<short[2]>::f() noexcept { h(); } + +// CHECK: define {{.*}} @_Z1fIDsEvv() { +template void f<char16_t>(); +// CHECK: define {{.*}} @_Z1fIA2_DsEvv() nounwind { +template void f<char16_t[2]>(); + +// CHECK: define {{.*}} @_ZN1SIDsE1fEv() +// CHECK-NOT: nounwind +template void S<char16_t>::f(); +// CHECK: define {{.*}} @_ZN1SIA2_DsE1fEv() nounwind +template void S<char16_t[2]>::f(); + +void h() { + // CHECK: define {{.*}} @_Z1fIiEvv() nounwind { + f<int>(); + // CHECK: define {{.*}} @_Z1fIA2_iEvv() { + f<int[2]>(); + + // CHECK: define {{.*}} @_ZN1SIiE1fEv() nounwind + S<int>::f(); + // CHECK: define {{.*}} @_ZN1SIA2_iE1fEv() + // CHECK-NOT: nounwind + S<int[2]>::f(); + + // CHECK: define {{.*}} @_Z1fIfEvv() nounwind { + void (*f1)() = &f<float>; + // CHECK: define {{.*}} @_Z1fIdEvv() { + void (*f2)() = &f<double>; + + // CHECK: define {{.*}} @_ZN1SIfE1fEv() nounwind + void (*f3)() = &S<float>::f; + // CHECK: define {{.*}} @_ZN1SIdE1fEv() + // CHECK-NOT: nounwind + void (*f4)() = &S<double>::f; + + // CHECK: define {{.*}} @_Z1fIA4_cEvv() nounwind { + (void)&f<char[4]>; + // CHECK: define {{.*}} @_Z1fIcEvv() { + (void)&f<char>; + + // CHECK: define {{.*}} @_ZN1SIA4_cE1fEv() nounwind + (void)&S<char[4]>::f; + // CHECK: define {{.*}} @_ZN1SIcE1fEv() + // CHECK-NOT: nounwind + (void)&S<char>::f; +} + +// CHECK: define {{.*}} @_Z1iv +void i() { + // CHECK: declare {{.*}} @_Z1gIiEvv() nounwind + g<int>(); + // CHECK: declare {{.*}} @_Z1gIA2_iEvv() + // CHECK-NOT: nounwind + g<int[2]>(); + + // CHECK: declare {{.*}} @_ZN1SIiE1gEv() nounwind + S<int>::g(); + // CHECK: declare {{.*}} @_ZN1SIA2_iE1gEv() + // CHECK-NOT: nounwind + S<int[2]>::g(); + + // CHECK: declare {{.*}} @_Z1gIfEvv() nounwind + void (*g1)() = &g<float>; + // CHECK: declare {{.*}} @_Z1gIdEvv() + // CHECK-NOT: nounwind + void (*g2)() = &g<double>; + + // CHECK: declare {{.*}} @_ZN1SIfE1gEv() nounwind + void (*g3)() = &S<float>::g; + // CHECK: declare {{.*}} @_ZN1SIdE1gEv() + // CHECK-NOT: nounwind + void (*g4)() = &S<double>::g; + + // CHECK: declare {{.*}} @_Z1gIA4_cEvv() nounwind + (void)&g<char[4]>; + // CHECK: declare {{.*}} @_Z1gIcEvv() + // CHECK-NOT: nounwind + (void)&g<char>; + + // CHECK: declare {{.*}} @_ZN1SIA4_cE1gEv() nounwind + (void)&S<char[4]>::g; + // CHECK: declare {{.*}} @_ZN1SIcE1gEv() + // CHECK-NOT: nounwind + (void)&S<char>::g; +} + +template<typename T> struct Nested { + template<bool b, typename U> void f() noexcept(sizeof(T) == sizeof(U)); +}; + +// CHECK: define {{.*}} @_Z1jv +void j() { + // CHECK: declare {{.*}} @_ZN6NestedIiE1fILb1EcEEvv( + // CHECK-NOT: nounwind + Nested<int>().f<true, char>(); + // CHECK: declare {{.*}} @_ZN6NestedIlE1fILb0ElEEvv({{.*}}) nounwind + Nested<long>().f<false, long>(); +} diff --git a/test/CodeGenCXX/inheriting-constructor.cpp b/test/CodeGenCXX/inheriting-constructor.cpp index b921a6d..a998402 100644 --- a/test/CodeGenCXX/inheriting-constructor.cpp +++ b/test/CodeGenCXX/inheriting-constructor.cpp @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s +// XFAIL: * + // PR12219 struct A { A(int); virtual ~A(); }; struct B : A { using A::A; ~B(); }; diff --git a/test/CodeGenCXX/mangle-this-cxx11.cpp b/test/CodeGenCXX/mangle-this-cxx11.cpp new file mode 100644 index 0000000..f9e9479 --- /dev/null +++ b/test/CodeGenCXX/mangle-this-cxx11.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 | FileCheck %s + +struct B { + template <class U> U f(); +}; + +struct A { + B b; + // implicitly rewritten to (*this).b.f<U>() + template <class U> auto f() -> decltype (b.f<U>()); + template <class U> auto g() -> decltype (this->b.f<U>()); +}; + +int main() { + A a; + // CHECK: call i32 @_ZN1A1fIiEEDTcldtdtdefpT1b1fIT_EEEv + a.f<int>(); + // CHECK: call i32 @_ZN1A1gIiEEDTcldtptfpT1b1fIT_EEEv + a.g<int>(); +} diff --git a/test/CodeGenCXX/static-init.cpp b/test/CodeGenCXX/static-init.cpp index ed659de..74278f7 100644 --- a/test/CodeGenCXX/static-init.cpp +++ b/test/CodeGenCXX/static-init.cpp @@ -2,6 +2,7 @@ // CHECK: @_ZZ1hvE1i = internal global i32 0, align 4 // CHECK: @base_req = global [4 x i8] c"foo\00", align 1 +// CHECK: @base_req_uchar = global [4 x i8] c"bar\00", align 1 // CHECK: @_ZZN5test31BC1EvE1u = internal global { i8, [3 x i8] } { i8 97, [3 x i8] undef }, align 4 // CHECK: @_ZZN5test1L6getvarEiE3var = internal constant [4 x i32] [i32 1, i32 0, i32 2, i32 4], align 16 @@ -64,6 +65,7 @@ namespace test1 { // Make sure we emit the initializer correctly for the following: char base_req[] = { "foo" }; +unsigned char base_req_uchar[] = { "bar" }; namespace union_static_local { // CHECK: define internal void @_ZZN18union_static_local4testEvEN1c4mainEv diff --git a/test/CodeGenOpenCL/fpaccuracy.cl b/test/CodeGenOpenCL/fpmath.cl index d27316a..704fcd7 100644 --- a/test/CodeGenOpenCL/fpaccuracy.cl +++ b/test/CodeGenOpenCL/fpmath.cl @@ -4,13 +4,13 @@ typedef __attribute__(( ext_vector_type(4) )) float float4; float spscalardiv(float a, float b) { // CHECK: @spscalardiv - // CHECK: fdiv{{.*}}, !fpaccuracy ![[MD:[0-9]+]] + // CHECK: fdiv{{.*}}, !fpmath ![[MD:[0-9]+]] return a / b; } float4 spvectordiv(float4 a, float4 b) { // CHECK: @spvectordiv - // CHECK: fdiv{{.*}}, !fpaccuracy ![[MD]] + // CHECK: fdiv{{.*}}, !fpmath ![[MD]] return a / b; } @@ -18,7 +18,7 @@ float4 spvectordiv(float4 a, float4 b) { double dpscalardiv(double a, double b) { // CHECK: @dpscalardiv - // CHECK-NOT: !fpaccuracy + // CHECK-NOT: !fpmath return a / b; } diff --git a/test/Headers/typedef_guards.c b/test/Headers/typedef_guards.c index 1aa667b..646b2ca0 100644 --- a/test/Headers/typedef_guards.c +++ b/test/Headers/typedef_guards.c @@ -1,4 +1,4 @@ -// RUN: %clang -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify %s // NULL is rdefined in stddef.h #define NULL ((void*) 0) diff --git a/test/Index/get-cursor.m b/test/Index/get-cursor.m index 60e35ee..5ac3375 100644 --- a/test/Index/get-cursor.m +++ b/test/Index/get-cursor.m @@ -60,6 +60,15 @@ void foo3(Test3 *test3) { [test3 setFoo:2 withBar:4]; } +@interface Test4 +@end +@interface Test4(Dido) +@end +@implementation Test4(Dido) +@end + +@class Forw1, Forw2, Forw3; + // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s // CHECK-PROP: ObjCPropertyDecl=foo1:4:26 // CHECK-PROP: ObjCPropertyDecl=foo2:5:27 @@ -82,6 +91,14 @@ void foo3(Test3 *test3) { // CHECK-MEMBERREF: 52:11 MemberRefExpr=setImplicitProp::46:8 Extent=[52:5 - 52:23] Spelling=setImplicitProp: ([52:11 - 52:23]) // RUN: c-index-test -cursor-at=%s:56:24 -cursor-at=%s:60:14 \ +// RUN: -cursor-at=%s:65:20 -cursor-at=%s:67:25 \ +// RUN: -cursor-at=%s:70:10 -cursor-at=%s:70:16 -cursor-at=%s:70:25 \ // RUN: %s | FileCheck -check-prefix=CHECK-SPELLRANGE %s // CHECK-SPELLRANGE: 56:8 ObjCInstanceMethodDecl=setFoo:withBar::56:8 Extent=[56:1 - 56:37] Spelling=setFoo:withBar: ([56:8 - 56:14][56:22 - 56:29]) Selector index=1 // CHECK-SPELLRANGE: 60:3 ObjCMessageExpr=setFoo:withBar::56:8 Extent=[60:3 - 60:29] Spelling=setFoo:withBar: ([60:10 - 60:16][60:19 - 60:26]) Selector index=0 +// CHECK-SPELLRANGE: 65:12 ObjCCategoryDecl=Dido:65:12 Extent=[65:1 - 66:5] Spelling=Dido ([65:18 - 65:22]) +// CHECK-SPELLRANGE: 67:17 ObjCCategoryImplDecl=Dido:67:17 (Definition) Extent=[67:1 - 68:2] Spelling=Dido ([67:23 - 67:27]) + +// CHECK-SPELLRANGE: 70:8 ObjCClassRef=Forw1:70:8 Extent=[70:8 - 70:13] Spelling=Forw1 ([70:8 - 70:13]) +// CHECK-SPELLRANGE: 70:15 ObjCClassRef=Forw2:70:15 Extent=[70:15 - 70:20] Spelling=Forw2 ([70:15 - 70:20]) +// CHECK-SPELLRANGE: 70:22 ObjCClassRef=Forw3:70:22 Extent=[70:22 - 70:27] Spelling=Forw3 ([70:22 - 70:27]) diff --git a/test/Lexer/newline-eof-c++98-compat.cpp b/test/Lexer/newline-eof-c++98-compat.cpp index 7f7eebb..3e5c8e2 100644 --- a/test/Lexer/newline-eof-c++98-compat.cpp +++ b/test/Lexer/newline-eof-c++98-compat.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -cc1 -fsyntax-only -Wc++98-compat-pedantic -std=c++11 -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wc++98-compat-pedantic -std=c++11 -verify %s // The following line isn't terminated, don't fix it. void foo() {} // expected-warning{{C++98 requires newline at end of file}}
\ No newline at end of file diff --git a/test/Lexer/newline-eof.c b/test/Lexer/newline-eof.c index 12087b2..825a266 100644 --- a/test/Lexer/newline-eof.c +++ b/test/Lexer/newline-eof.c @@ -1,4 +1,4 @@ -// RUN: %clang -cc1 -fsyntax-only -Wnewline-eof -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wnewline-eof -verify %s // rdar://9133072 // The following line isn't terminated, don't fix it. diff --git a/test/Lexer/utf-16.c b/test/Lexer/utf-16.c index 2b313e4..169ee43 100644 --- a/test/Lexer/utf-16.c +++ b/test/Lexer/utf-16.c @@ -1,4 +1,4 @@ -// RUN: not %clang %s -fsyntax-only -verify +// RUN: %clang_cc1 %s -fsyntax-only -verify // rdar://7876588 // This test verifies that clang gives a decent error for UTF-16 source files. diff --git a/test/Misc/message-length.c b/test/Misc/message-length.c index 3e69b6a..a6f4f44 100644 --- a/test/Misc/message-length.c +++ b/test/Misc/message-length.c @@ -27,9 +27,8 @@ void a_very_long_line(int *ip, float *FloatPointer) { #pragma STDC CX_LIMITED_RANGE // some long comment text and a brace, eh {} - // CHECK: FILE:23:78 -// CHECK: {{^ ...// some long comment text and a brace, eh {} }} +// CHECK: {{^ ...// some long comment text and a brace, eh {}}} struct A { int x; }; void h(struct A *a) { diff --git a/test/Misc/pubnames.c b/test/Misc/pubnames.c deleted file mode 100644 index 0304897..0000000 --- a/test/Misc/pubnames.c +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: %clang_cc1 -pubnames-dump %s | FileCheck %s -#define FOO -#define BAR -#undef FOO -#define WIBBLE - -int foo(); -int bar(float); -int wibble; - -// CHECK: BAR -// CHECK-NOT: FOO -// CHECK: WIBBLE -// CHECK-NOT: __clang_major__ -// CHECK: bar -// CHECK: foo -// CHECK: wibble - - diff --git a/test/Misc/unprintable.c b/test/Misc/unprintable.c new file mode 100644 index 0000000..860503e --- /dev/null +++ b/test/Misc/unprintable.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 %s 2>&1 | FileCheck -strict-whitespace %s + +int main() { + int i; + if((i==/*👿*/1)); + +// CHECK: {{^ if\(\(i==/\*<U\+1F47F>\*/1\)\);}} + +// CHECK: {{^ ~\^~~~~~~~~~~~~~~~}} +// CHECK: {{^ ~ \^ ~}} + + /* 👿 */ "👿berhund"; + +// CHECK: {{^ /\* <U\+1F47F> \*/ "<U\+1F47F>berhund";}} +// CHECK: {{^ \^~~~~~~~~~~~~~~~~~}} +}
\ No newline at end of file diff --git a/test/Misc/wnull-character.cpp b/test/Misc/wnull-character.cpp Binary files differnew file mode 100644 index 0000000..a618da2 --- /dev/null +++ b/test/Misc/wnull-character.cpp diff --git a/test/Misc/wrong-encoding.c b/test/Misc/wrong-encoding.c new file mode 100644 index 0000000..bd1cf3d --- /dev/null +++ b/test/Misc/wrong-encoding.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s + +void foo() { + + "§Ã"; // ø +// CHECK: {{^ "<A7><C3>"; // <F8>}} +// CHECK: {{^ \^}} + + /* þ« */ const char *d = "¥"; + +// CHECK: {{^ /\* <FE><AB> \*/ const char \*d = "<A5>";}} +// CHECK: {{^ \^}} + +// CHECK: {{^ "<A7><C3>"; // <F8>}} +// CHECK: {{^ \^~~~~~~~~~}} +} diff --git a/test/PCH/typo2.cpp b/test/PCH/typo2.cpp new file mode 100644 index 0000000..f9b4c83 --- /dev/null +++ b/test/PCH/typo2.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-pch %s -o %t.pch +// RUN: %clang_cc1 -include-pch %t.pch %s -verify + +#ifndef HEADER_INCLUDED +#define HEADER_INCLUDED + +void func(struct Test); // expected-note{{'Test' declared here}} + +#else + +::Yest *T; // expected-error{{did you mean 'Test'}} + +#endif diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index 89394c3..3a1ffea 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fdelayed-template-parsing +// RUN: %clang_cc1 %s -std=c++11 -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions -fms-compatibility -fdelayed-template-parsing /* Microsoft attribute tests */ [repeatable][source_annotation_attribute( Parameter|ReturnValue )] @@ -103,7 +103,7 @@ typedef COM_CLASS_TEMPLATE<struct_with_uuid> COM_TYPE_2; template <class T, const GUID& g> class COM_CLASS_TEMPLATE_REF { }; -typedef COM_CLASS_TEMPLATE<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF; +typedef COM_CLASS_TEMPLATE_REF<struct_with_uuid, __uuidof(struct_with_uuid)> COM_TYPE_REF; struct late_defined_uuid; template<typename T> @@ -284,3 +284,28 @@ int main () { missing_template_keyword<int>(); } + + +
+namespace access_protected_PTM {
+
+class A {
+protected:
+ void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}}
+};
+
+class B : public A{
+public:
+ void test_access();
+ static void test_access_static();
+};
+
+void B::test_access() {
+ &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}}
+}
+
+void B::test_access_static() {
+ &A::f;
+}
+
+}
\ No newline at end of file diff --git a/test/Parser/cxx11-stmt-attributes.cpp b/test/Parser/cxx11-stmt-attributes.cpp new file mode 100644 index 0000000..fab5621 --- /dev/null +++ b/test/Parser/cxx11-stmt-attributes.cpp @@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s + +void foo(int i) { + + [[unknown_attribute]] ; + [[unknown_attribute]] { } + [[unknown_attribute]] if (0) { } + [[unknown_attribute]] for (;;); + [[unknown_attribute]] do { + [[unknown_attribute]] continue; + } while (0); + [[unknown_attribute]] while (0); + + [[unknown_attribute]] switch (i) { + [[unknown_attribute]] case 0: + [[unknown_attribute]] default: + [[unknown_attribute]] break; + } + + [[unknown_attribute]] goto here; + [[unknown_attribute]] here: + + [[unknown_attribute]] try { + } catch (...) { + } + + [[unknown_attribute]] return; + + + alignas(8) ; // expected-warning {{attribute aligned cannot be specified on a statement}} + [[noreturn]] { } // expected-warning {{attribute noreturn cannot be specified on a statement}} + [[noreturn]] if (0) { } // expected-warning {{attribute noreturn cannot be specified on a statement}} + [[noreturn]] for (;;); // expected-warning {{attribute noreturn cannot be specified on a statement}} + [[noreturn]] do { // expected-warning {{attribute noreturn cannot be specified on a statement}} + [[unavailable]] continue; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here + } while (0); + [[unknown_attributqqq]] while (0); // TODO: remove 'qqq' part and enjoy 'empty loop body' warning here (DiagnoseEmptyLoopBody) + [[unknown_attribute]] while (0); // no warning here yet, just an unknown attribute + + [[unused]] switch (i) { // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here + [[uuid]] case 0: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here + [[visibility]] default: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here + [[carries_dependency]] break; // expected-warning {{attribute carries_dependency cannot be specified on a statement}} + } + + [[fastcall]] goto there; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here + [[noinline]] there: // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here + + [[lock_returned]] try { // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here + } catch (...) { + } + + [[weakref]] return; // TODO: only noreturn, alignas and carries_dependency are parsed in C++ 11 syntax at the moment, hence no warning here +} diff --git a/test/Parser/objcxx11-attributes.mm b/test/Parser/objcxx11-attributes.mm index 0875b66..0c91392 100644 --- a/test/Parser/objcxx11-attributes.mm +++ b/test/Parser/objcxx11-attributes.mm @@ -31,15 +31,17 @@ void f(X *noreturn) { // An attribute is OK. [[]]; - [[int(), noreturn]]; + [[int(), noreturn]]; // expected-warning {{attribute noreturn cannot be specified on a statement}} [[class, test(foo 'x' bar),,,]]; - [[bitand, noreturn]]; + [[bitand, noreturn]]; // expected-warning {{attribute noreturn cannot be specified on a statement}} [[noreturn]]int(e)(); + int e2(); // expected-warning {{interpreted as a function declaration}} expected-note{{}} // A function taking a noreturn function. - int(f)([[noreturn]] int()); + int(f)([[noreturn]] int()); // expected-note {{here}} f(e); + f(e2); // expected-error {{cannot initialize a parameter of type 'int (*)() __attribute__((noreturn))' with an lvalue of type 'int ()'}} // Variables initialized by a message send. int(g)([[noreturn getSelf] getSize]); diff --git a/test/Preprocessor/pragma_sysheader.c b/test/Preprocessor/pragma_sysheader.c index 2641682..17080fe 100644 --- a/test/Preprocessor/pragma_sysheader.c +++ b/test/Preprocessor/pragma_sysheader.c @@ -1,4 +1,4 @@ -// RUN: %clang -verify -pedantic %s -fsyntax-only +// RUN: %clang_cc1 -verify -pedantic %s -fsyntax-only // RUN: %clang_cc1 -E %s | FileCheck %s // rdar://6899937 #include "pragma_sysheader.h" diff --git a/test/Rewriter/blockcast3.mm b/test/Rewriter/blockcast3.mm index 8b35528..ceafcff 100644 --- a/test/Rewriter/blockcast3.mm +++ b/test/Rewriter/blockcast3.mm @@ -1,5 +1,8 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -E %s -o %t.mm +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %t.mm -o %t-rw.cpp // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o %t-modern-rw.cpp +// RUN: FileCheck -check-prefix LP --input-file=%t-modern-rw.cpp %s // radar 7607781 typedef struct { @@ -20,4 +23,4 @@ void f(const void **arg) { }); } -// CHECK-LP: (struct __Block_byref_q_0 *)&q +// CHECK-LP: (__Block_byref_q_0 *)&q diff --git a/test/Rewriter/instancetype-test.mm b/test/Rewriter/instancetype-test.mm index a92a3f7..7885055 100644 --- a/test/Rewriter/instancetype-test.mm +++ b/test/Rewriter/instancetype-test.mm @@ -1,5 +1,7 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp -// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp void *sel_registerName(const char *); diff --git a/test/Rewriter/objc-bool-literal-check-modern.mm b/test/Rewriter/objc-bool-literal-check-modern.mm index b28e594..3386197 100644 --- a/test/Rewriter/objc-bool-literal-check-modern.mm +++ b/test/Rewriter/objc-bool-literal-check-modern.mm @@ -2,7 +2,7 @@ // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s // rdar://11124775 -typedef signed char BOOL; +typedef bool BOOL; BOOL yes() { return __objc_yes; @@ -22,8 +22,8 @@ int main() { return __objc_yes; } -// CHECK: return ((signed char)1); -// CHECK: return ((signed char)0); -// CHECK: which (((signed char)1)); -// CHECK: which (((signed char)0)); -// CHECK: return ((signed char)1); +// CHECK: return ((bool)1); +// CHECK: return ((bool)0); +// CHECK: which (((bool)1)); +// CHECK: which (((bool)0)); +// CHECK: return ((bool)1); diff --git a/test/Rewriter/objc-bool-literal-modern.mm b/test/Rewriter/objc-bool-literal-modern.mm index 6bbbb44..328ee6b 100644 --- a/test/Rewriter/objc-bool-literal-modern.mm +++ b/test/Rewriter/objc-bool-literal-modern.mm @@ -2,7 +2,7 @@ // RUN: %clang_cc1 -fsyntax-only -D"__declspec(X)=" %t-rw.cpp // rdar://11124775 -typedef signed char BOOL; +typedef bool BOOL; BOOL yes() { return __objc_yes; diff --git a/test/Rewriter/objc-modern-numeric-literal.mm b/test/Rewriter/objc-modern-numeric-literal.mm index d27d03d..5f0b1fc 100644 --- a/test/Rewriter/objc-modern-numeric-literal.mm +++ b/test/Rewriter/objc-modern-numeric-literal.mm @@ -4,7 +4,7 @@ extern "C" void *sel_registerName(const char *); -typedef signed char BOOL; +typedef bool BOOL; typedef long NSInteger; typedef unsigned long NSUInteger; @@ -63,7 +63,7 @@ int main(int argc, const char *argv[]) { // CHECK: NSNumber *fortyTwoLongLong = ((NSNumber *(*)(id, SEL, long long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLongLong:"), 42LL); // CHECK: NSNumber *piFloat = ((NSNumber *(*)(id, SEL, float))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithFloat:"), 3.1415927); // CHECK: NSNumber *piDouble = ((NSNumber *(*)(id, SEL, double))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithDouble:"), 3.1415926535); -// CHECK: NSNumber *yesNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)true); -// CHECK: NSNumber *noNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)false); -// CHECK: NSNumber *trueNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)true); -// CHECK: NSNumber *falseNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)false); +// CHECK: NSNumber *yesNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), true); +// CHECK: NSNumber *noNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), false); +// CHECK: NSNumber *trueNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), true); +// CHECK: NSNumber *falseNumber = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), false); diff --git a/test/Rewriter/rewrite-block-consts.mm b/test/Rewriter/rewrite-block-consts.mm index fca10ed..1d6de8c 100644 --- a/test/Rewriter/rewrite-block-consts.mm +++ b/test/Rewriter/rewrite-block-consts.mm @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp -// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D__block="" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar:// 8243071 void x(int y) {} diff --git a/test/Rewriter/rewrite-block-literal-1.mm b/test/Rewriter/rewrite-block-literal-1.mm index 5213f50..f152117 100644 --- a/test/Rewriter/rewrite-block-literal-1.mm +++ b/test/Rewriter/rewrite-block-literal-1.mm @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 9254348 +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp +// rdar://11259664 void *sel_registerName(const char *); typedef void (^BLOCK_TYPE)(void); diff --git a/test/Rewriter/rewrite-block-literal.mm b/test/Rewriter/rewrite-block-literal.mm index 732d0b9..083312e 100644 --- a/test/Rewriter/rewrite-block-literal.mm +++ b/test/Rewriter/rewrite-block-literal.mm @@ -1,7 +1,9 @@ // RUN: %clang_cc1 -E %s -o %t.mm // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp -// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // rdar: // 11006566 diff --git a/test/Rewriter/rewrite-block-pointer.mm b/test/Rewriter/rewrite-block-pointer.mm index 4838b74..58407a7 100644 --- a/test/Rewriter/rewrite-block-pointer.mm +++ b/test/Rewriter/rewrite-block-pointer.mm @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7638400 typedef void * id; diff --git a/test/Rewriter/rewrite-byref-in-nested-blocks.mm b/test/Rewriter/rewrite-byref-in-nested-blocks.mm index b1ff46b..a659383 100644 --- a/test/Rewriter/rewrite-byref-in-nested-blocks.mm +++ b/test/Rewriter/rewrite-byref-in-nested-blocks.mm @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7692350 void f(void (^block)(void)); diff --git a/test/Rewriter/rewrite-elaborated-type.mm b/test/Rewriter/rewrite-elaborated-type.mm index bef56b9..a0c7e43 100644 --- a/test/Rewriter/rewrite-elaborated-type.mm +++ b/test/Rewriter/rewrite-elaborated-type.mm @@ -1,5 +1,7 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 8143056 typedef struct objc_class *Class; @@ -29,6 +31,8 @@ struct NSSlice { } @end +@interface I1 @end + @implementation I1 + (struct s1 *) f0 { return 0; diff --git a/test/Rewriter/rewrite-foreach-in-block.mm b/test/Rewriter/rewrite-foreach-in-block.mm index d0a8728..fd34212 100644 --- a/test/Rewriter/rewrite-foreach-in-block.mm +++ b/test/Rewriter/rewrite-foreach-in-block.mm @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // rdar:// 9878420 void objc_enumerationMutation(id); diff --git a/test/Rewriter/rewrite-modern-container-literal.mm b/test/Rewriter/rewrite-modern-container-literal.mm index 87b9b89..2c2f61d 100644 --- a/test/Rewriter/rewrite-modern-container-literal.mm +++ b/test/Rewriter/rewrite-modern-container-literal.mm @@ -5,7 +5,7 @@ void *sel_registerName(const char *); typedef unsigned long NSUInteger; typedef long NSInteger; -typedef signed char BOOL; +typedef bool BOOL; @interface NSNumber + (NSNumber *)numberWithChar:(char)value; diff --git a/test/Rewriter/rewrite-modern-extern-c-func-decl.mm b/test/Rewriter/rewrite-modern-extern-c-func-decl.mm new file mode 100644 index 0000000..10023bb --- /dev/null +++ b/test/Rewriter/rewrite-modern-extern-c-func-decl.mm @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -fms-extensions -rewrite-objc -x objective-c++ -fblocks -o %t-rw.cpp %s +// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// rdar://11131490 + +// XFAIL: mingw +// FIXME: __declspec(X) is predefined on mingw. + +extern "C" __declspec(dllexport) void BreakTheRewriter(void) { + __block int aBlockVariable = 0; + void (^aBlock)(void) = ^ { + aBlockVariable = 42; + }; + aBlockVariable++; + void (^bBlocks)(void) = ^ { + aBlockVariable = 43; + }; + void (^c)(void) = ^ { + aBlockVariable = 44; + }; + +} +__declspec(dllexport) extern "C" void AnotherBreakTheRewriter(int *p1, double d) { + + __block int bBlockVariable = 0; + void (^aBlock)(void) = ^ { + bBlockVariable = 42; + }; + bBlockVariable++; + void (^bBlocks)(void) = ^ { + bBlockVariable = 43; + }; + void (^c)(void) = ^ { + bBlockVariable = 44; + }; + +} + +int + +__declspec (dllexport) + +main (int argc, char *argv[]) +{ + __block int bBlockVariable = 0; + void (^aBlock)(void) = ^ { + bBlockVariable = 42; + }; +} diff --git a/test/Rewriter/rewrite-modern-protocol-1.mm b/test/Rewriter/rewrite-modern-protocol-1.mm new file mode 100644 index 0000000..7b737fe --- /dev/null +++ b/test/Rewriter/rewrite-modern-protocol-1.mm @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -E %s -o %t.mm +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s +// rdar://11248048 + +@protocol NSCopying @end + +@interface INTF<NSCopying> +@end + +@implementation INTF @end + +// CHECK: static struct _protocol_t _OBJC_PROTOCOL_NSCopying +// CHECK: static struct _protocol_t *_OBJC_LABEL_PROTOCOL_$_NSCopying = &_OBJC_PROTOCOL_NSCopying; + diff --git a/test/Rewriter/rewrite-modern-super.mm b/test/Rewriter/rewrite-modern-super.mm new file mode 100644 index 0000000..ee397b3 --- /dev/null +++ b/test/Rewriter/rewrite-modern-super.mm @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=struct objc_object *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// rdar://11239894 + +extern "C" void *sel_registerName(const char *); + +typedef struct objc_class * Class; + +@interface Sub +- (void)dealloc; +@end + +@interface I : Sub +- (void)dealloc; +@end + +@implementation I +- (void)dealloc { + return; + [super dealloc]; +} +@end + diff --git a/test/Rewriter/rewrite-modern-typeof.mm b/test/Rewriter/rewrite-modern-typeof.mm new file mode 100644 index 0000000..4650ab7 --- /dev/null +++ b/test/Rewriter/rewrite-modern-typeof.mm @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp + +extern "C" { +extern "C" void *_Block_copy(const void *aBlock); +extern "C" void _Block_release(const void *aBlock); +} + +int main() { + __attribute__((__blocks__(byref))) int a = 42; + int save_a = a; + + void (^b)(void) = ^{ + ((__typeof(^{ a = 2; }))_Block_copy((const void *)(^{ a = 2; }))); + }; + + ((__typeof(b))_Block_copy((const void *)(b))); + + return 0; +} + +// CHECK-LP: ((void (^)(void))_Block_copy((const void *)(b))) + +// radar 7628153 +void f() { + int a; + __typeof__(a) aVal = a; + char *a1t = (char *)@encode(__typeof__(a)); + __typeof__(aVal) bVal; + char *a2t = (char *)@encode(__typeof__(bVal)); + __typeof__(bVal) cVal = bVal; + char *a3t = (char *)@encode(__typeof__(cVal)); + +} + +// rdar://11239324 +void x() { + id y; + void (^z)() = ^{ }; + y = (id)((__typeof(z))_Block_copy((const void *)(z))); +} + +// CHECK-LP: int aVal = a; + +// CHECK-LP: int bVal; diff --git a/test/Rewriter/rewrite-nested-blocks-1.mm b/test/Rewriter/rewrite-nested-blocks-1.mm index 672486b..25b17cf 100644 --- a/test/Rewriter/rewrite-nested-blocks-1.mm +++ b/test/Rewriter/rewrite-nested-blocks-1.mm @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7696893 void *sel_registerName(const char *); diff --git a/test/Rewriter/rewrite-nested-blocks-2.mm b/test/Rewriter/rewrite-nested-blocks-2.mm index 1555767..d1513f3 100644 --- a/test/Rewriter/rewrite-nested-blocks-2.mm +++ b/test/Rewriter/rewrite-nested-blocks-2.mm @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // grep "static void __FUNC_block_copy_" %t-rw.cpp | count 2 +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp +// grep "static void __FUNC_block_copy_" %t-modern-rw.cpp | count 2 // rdar://8499592 void Outer(void (^bk)()); diff --git a/test/Rewriter/rewrite-nested-blocks.mm b/test/Rewriter/rewrite-nested-blocks.mm index 6c860ef..d492afa 100644 --- a/test/Rewriter/rewrite-nested-blocks.mm +++ b/test/Rewriter/rewrite-nested-blocks.mm @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7682149 diff --git a/test/Rewriter/rewrite-nested-property-in-blocks.mm b/test/Rewriter/rewrite-nested-property-in-blocks.mm index 6a03d73..7f9361e 100755 --- a/test/Rewriter/rewrite-nested-property-in-blocks.mm +++ b/test/Rewriter/rewrite-nested-property-in-blocks.mm @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 8608293 void *sel_registerName(const char *); diff --git a/test/Rewriter/rewrite-unique-block-api.mm b/test/Rewriter/rewrite-unique-block-api.mm index 2c0c4a9..1dcc1b6 100644 --- a/test/Rewriter/rewrite-unique-block-api.mm +++ b/test/Rewriter/rewrite-unique-block-api.mm @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7630551 void f(void (^b)(char c)); diff --git a/test/Sema/const-eval-64.c b/test/Sema/const-eval-64.c new file mode 100644 index 0000000..5727a93 --- /dev/null +++ b/test/Sema/const-eval-64.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux %s + +#define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];}); + +// <rdar://problem/10962435> +EVAL_EXPR(1, ((char*)-1LL) + 1 == 0 ? 1 : -1) +EVAL_EXPR(2, ((char*)-1LL) + 1 < (char*) -1 ? 1 : -1) diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index f1c0485..bc8b227 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -121,3 +121,13 @@ EVAL_EXPR(43, varfloat && constfloat) // expected-error {{must have a constant s // <rdar://problem/11205586> // (Make sure we continue to reject this.) EVAL_EXPR(44, "x"[0]); // expected-error {{variable length array}} + +// <rdar://problem/10962435> +EVAL_EXPR(45, ((char*)-1) + 1 == 0 ? 1 : -1) +EVAL_EXPR(46, ((char*)-1) + 1 < (char*) -1 ? 1 : -1) +EVAL_EXPR(47, &x < &x + 1 ? 1 : -1) +EVAL_EXPR(48, &x != &x - 1 ? 1 : -1) +EVAL_EXPR(49, &x < &x - 100 ? 1 : -1) // expected-error {{must have a constant size}} + +extern struct Test50S Test50; +EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-error {{must have a constant size}} diff --git a/test/Sema/surpress-deprecated.c b/test/Sema/surpress-deprecated.c index 78faf22..dd673b9 100644 --- a/test/Sema/surpress-deprecated.c +++ b/test/Sema/surpress-deprecated.c @@ -1,4 +1,4 @@ -// RUN: %clang -fsyntax-only -Wno-deprecated-declarations -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-declarations -verify %s extern void OldFunction() __attribute__((deprecated)); int main (int argc, const char * argv[]) { diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp index 41d214a..9f80e71 100644 --- a/test/SemaCXX/constant-expression-cxx11.cpp +++ b/test/SemaCXX/constant-expression-cxx11.cpp @@ -615,6 +615,10 @@ static_assert(agg1.arr[4] == 0, ""); static_assert(agg1.arr[5] == 0, ""); // expected-error {{constant expression}} expected-note {{read of dereferenced one-past-the-end}} static_assert(agg1.p == nullptr, ""); +static constexpr const unsigned char uc[] = { "foo" }; +static_assert(uc[0] == 'f', ""); +static_assert(uc[3] == 0, ""); + namespace SimpleDerivedClass { struct B { diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp index 4758913..82a9dc8 100644 --- a/test/SemaCXX/cxx98-compat.cpp +++ b/test/SemaCXX/cxx98-compat.cpp @@ -114,12 +114,16 @@ bool no_except_expr = noexcept(1 + 1); // expected-warning {{noexcept expression void *null = nullptr; // expected-warning {{'nullptr' is incompatible with C++98}} static_assert(true, "!"); // expected-warning {{static_assert declarations are incompatible with C++98}} +// FIXME: Reintroduce this test if support for inheriting constructors is +// implemented. +#if 0 struct InhCtorBase { InhCtorBase(int); }; struct InhCtorDerived : InhCtorBase { - using InhCtorBase::InhCtorBase; // expected-warning {{inherited constructors are incompatible with C++98}} + using InhCtorBase::InhCtorBase; // xpected-warning {{inheriting constructors are incompatible with C++98}} }; +#endif struct FriendMember { static void MemberFn(); diff --git a/test/SemaCXX/dependent-noexcept-unevaluated.cpp b/test/SemaCXX/dependent-noexcept-unevaluated.cpp index 8066b85..fad8d09 100644 --- a/test/SemaCXX/dependent-noexcept-unevaluated.cpp +++ b/test/SemaCXX/dependent-noexcept-unevaluated.cpp @@ -23,7 +23,7 @@ struct array { T data[N]; - void swap(array& a) noexcept(noexcept(swap(declval<T&>(), declval<T&>()))); + void swap(array& a) noexcept(noexcept(::swap(declval<T&>(), declval<T&>()))); }; struct DefaultOnly diff --git a/test/SemaCXX/implicit-exception-spec.cpp b/test/SemaCXX/implicit-exception-spec.cpp index 786e8f4..143d9f7 100644 --- a/test/SemaCXX/implicit-exception-spec.cpp +++ b/test/SemaCXX/implicit-exception-spec.cpp @@ -39,20 +39,14 @@ namespace InClassInitializers { bool z = noexcept(Nested::Inner()); } -// FIXME: -// The same problem arises in delayed parsing of exception specifications, -// which clang does not yet support. namespace ExceptionSpecification { - struct Nested { // expected-note {{not complete}} + struct Nested { struct T { - T() noexcept(!noexcept(Nested())); // expected-error {{incomplete type}} + T() noexcept(!noexcept(Nested())); // expected-error{{exception specification is not available until end of class definition}} } t; }; } -// FIXME: -// The same problem arises in delayed parsing of default arguments, -// which clang does not yet support. namespace DefaultArgument { struct Default { struct T { diff --git a/test/SemaCXX/warn-everthing.cpp b/test/SemaCXX/warn-everthing.cpp index 144a8f9..ad3dd8a 100644 --- a/test/SemaCXX/warn-everthing.cpp +++ b/test/SemaCXX/warn-everthing.cpp @@ -1,4 +1,4 @@ -// RUN: %clang -Weverything -fsyntax-only %s -verify +// RUN: %clang_cc1 -Weverything -fsyntax-only %s -verify // This previously crashed due to a bug in the CFG. Exercising all // warnings helps check CFG construction. @@ -8,6 +8,6 @@ public: ~PR12271(); }; -void testPR12271() { - PR12271 a[1][1]; -}
\ No newline at end of file +void testPR12271() { // expected-warning {{no previous prototype for function 'testPR12271'}} + PR12271 a[1][1]; // expected-warning {{unused variable 'a'}} +} diff --git a/test/SemaCXX/warn-thread-safety-parsing.cpp b/test/SemaCXX/warn-thread-safety-parsing.cpp index 587cb8a..c2fa1d7 100644 --- a/test/SemaCXX/warn-thread-safety-parsing.cpp +++ b/test/SemaCXX/warn-thread-safety-parsing.cpp @@ -1255,7 +1255,7 @@ public: void foo4(FooLate *f) __attribute__((exclusive_locks_required(f->mu))); static void foo5() __attribute__((exclusive_locks_required(mu))); // \ - // expected-error {{invalid use of member 'mu' in static member function}} + // expected-error {{'this' cannot be implicitly used in a static member function declaration}} template <class T> void foo6() __attribute__((exclusive_locks_required(T::statmu))) { } diff --git a/test/SemaObjC/error-implicit-property.m b/test/SemaObjC/error-implicit-property.m new file mode 100644 index 0000000..ea0587a --- /dev/null +++ b/test/SemaObjC/error-implicit-property.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -verify %s +// rdar://11273060 + +@interface I +- (void) setP : (int)arg; +@end + +@interface J + - (int) P; +@end + +@interface K @end + +@interface II @end + +@implementation II +- (void) Meth : (I*) arg { + arg.P++; // expected-error {{no getter method 'P' for increment of property}} + --arg.P; // expected-error {{no getter method 'P' for decrement of property}} +} +- (void) Meth1 : (J*) arg { + arg.P++; // expected-error {{no setter method 'setP:' for increment of property}} + arg.P--; // expected-error {{no setter method 'setP:' for decrement of property}} +} + +- (void) Meth2 : (K*) arg { + arg.P++; // expected-error {{property 'P' not found on object of type 'K *'}} + arg.P--; // expected-error {{property 'P' not found on object of type 'K *'}} +} +@end diff --git a/test/SemaObjC/objc-literal-nsnumber.m b/test/SemaObjC/objc-literal-nsnumber.m index 449bfff..6635bea 100644 --- a/test/SemaObjC/objc-literal-nsnumber.m +++ b/test/SemaObjC/objc-literal-nsnumber.m @@ -78,8 +78,8 @@ NSDictionary * warn() { } // rdar:// 11231426 -typedef float BOOL; // expected-note {{previous declaration is here}} +typedef float BOOL; BOOL radar11231426() { - return __objc_yes; // expected-warning {{BOOL of type 'float' is non-intergal and unsuitable for a boolean literal - ignored}} + return __objc_yes; } diff --git a/test/SemaObjCXX/literals.mm b/test/SemaObjCXX/literals.mm index eed6765..6cdd207 100644 --- a/test/SemaObjCXX/literals.mm +++ b/test/SemaObjCXX/literals.mm @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -fblocks %s // rdar://11231426 -typedef bool BOOL; +typedef signed char BOOL; void y(BOOL (^foo)()); diff --git a/test/SemaObjCXX/property-reference.mm b/test/SemaObjCXX/property-reference.mm index 18f0604..b86ae5e 100644 --- a/test/SemaObjCXX/property-reference.mm +++ b/test/SemaObjCXX/property-reference.mm @@ -42,3 +42,18 @@ typedef const TCPPObject& CREF_TCPPObject; cppObjectNonAtomic = cppObject; } @end + + +// <rdar://problem/11052352> +@interface NSObject ++ alloc; +- init; +- class; +@end + +template<typename T> void f() { + NSObject *o = [NSObject.alloc init]; + [o class]; +} + +template void f<int>(); diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp index 5d301be..1eefa9f 100644 --- a/test/SemaTemplate/default-expr-arguments.cpp +++ b/test/SemaTemplate/default-expr-arguments.cpp @@ -292,3 +292,14 @@ namespace PR8401 { f(); } } + +namespace PR12581 { + const int a = 0; + template < typename > struct A; + template < typename MatrixType, int = + A < MatrixType >::Flags ? : A < MatrixType >::Flags & a > class B; + void + fn1 () + { + } +} diff --git a/test/SemaTemplate/dependent-names.cpp b/test/SemaTemplate/dependent-names.cpp index 36e1ad8..924bad9 100644 --- a/test/SemaTemplate/dependent-names.cpp +++ b/test/SemaTemplate/dependent-names.cpp @@ -292,3 +292,35 @@ namespace PR10187 { template void f<S>(); // expected-note {{here}} } } + +namespace rdar11242625 { + +template <typename T> +struct Main { + struct default_names { + typedef int id; + }; + + template <typename T2 = typename default_names::id> + struct TS { + T2 q; + }; +}; + +struct Sub : public Main<int> { + TS<> ff; +}; + +int arr[sizeof(Sub)]; + +} + +namespace PR11421 { +template < unsigned > struct X { + static const unsigned dimension = 3; + template<unsigned dim=dimension> + struct Y: Y<dim> { }; // expected-error {{incomplete type}} expected-note {{is not complete until the closing}} +}; +typedef X<3> X3; +X3::Y<>::iterator it; // expected-note {{requested here}} +} diff --git a/test/SemaTemplate/instantiate-declref.cpp b/test/SemaTemplate/instantiate-declref.cpp index ced56df..7d4a2ff 100644 --- a/test/SemaTemplate/instantiate-declref.cpp +++ b/test/SemaTemplate/instantiate-declref.cpp @@ -105,3 +105,13 @@ namespace test1 { } template void f(int const &); // expected-note {{requested here}} } + +namespace test2 { + template<typename T> void f() { + T::error; // expected-error {{no member}} + } + void g() { + // This counts as an odr-use, so should trigger the instantiation of f<int>. + (void)&f<int>; // expected-note {{here}} + } +} diff --git a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp new file mode 100644 index 0000000..8a6f9ef --- /dev/null +++ b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp @@ -0,0 +1,133 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -ftemplate-depth 16 -fcxx-exceptions -fexceptions %s + +// DR1330: an exception specification for a function template is only +// instantiated when it is needed. + +template<typename T> void f1(T*) throw(T); // expected-error{{incomplete type 'Incomplete' is not allowed in exception specification}} +struct Incomplete; // expected-note{{forward}} + +void test_f1(Incomplete *incomplete_p, int *int_p) { + f1(int_p); + f1(incomplete_p); // expected-note{{instantiation of exception spec}} +} + +template<typename T> struct A { + template<typename U> struct B { + static void f() noexcept(A<U>().n); + }; + + constexpr A() : n(true) {} + bool n; +}; + +static_assert(noexcept(A<int>::B<char>::f()), ""); + +template<unsigned N> struct S { + static void recurse() noexcept(noexcept(S<N+1>::recurse())); // \ + // expected-error {{no member named 'recurse'}} \ + // expected-note 9{{instantiation of exception spec}} +}; +decltype(S<0>::recurse()) *pVoid1 = 0; // ok, exception spec not needed +decltype(&S<0>::recurse) pFn = 0; // ok, exception spec not needed + +template<> struct S<10> {}; +void (*pFn2)() noexcept = &S<0>::recurse; // expected-note {{instantiation of exception spec}} expected-error {{not superset}} + + +template<typename T> T go(T a) noexcept(noexcept(go(a))); // \ +// expected-error 16{{call to function 'go' that is neither visible}} \ +// expected-note 16{{'go' should be declared prior to the call site}} \ +// expected-error {{recursive template instantiation exceeded maximum depth of 16}} \ +// expected-error {{use of undeclared identifier 'go'}} \ + +void f() { + int k = go(0); // \ + // expected-note {{in instantiation of exception specification for 'go<int>' requested here}} +} + + +namespace dr1330_example { + template <class T> struct A { + void f(...) throw (typename T::X); // expected-error {{'int'}} + void f(int); + }; + + int main() { + A<int>().f(42); + } + + int test2() { + struct S { + template<typename T> + static int f() noexcept(noexcept(A<T>().f("boo!"))) { return 0; } // \ + // expected-note {{instantiation of exception spec}} + typedef decltype(f<S>()) X; + }; + S().f<S>(); // ok + S().f<int>(); // expected-note {{instantiation of exception spec}} + } +} + +namespace core_19754_example { + template<typename T> T declval() noexcept; + + template<typename T, typename = decltype(T(declval<T&&>()))> + struct is_movable { static const bool value = true; }; + + template<typename T> + struct wrap { + T val; + void irrelevant(wrap &p) noexcept(is_movable<T>::value); + }; + + template<typename T> + struct base { + base() {} + base(const typename T::type1 &); + base(const typename T::type2 &); + }; + + template<typename T> + struct type1 { + wrap<typename T::base> base; + }; + + template<typename T> + struct type2 { + wrap<typename T::base> base; + }; + + struct types { + typedef base<types> base; + typedef type1<types> type1; + typedef type2<types> type2; + }; + + base<types> val = base<types>(); +} + +namespace pr9485 { + template <typename T> void f1(T) throw(typename T::exception); // expected-note {{candidate}} + template <typename T> void f1(T, int = 0) throw(typename T::noitpecxe); // expected-note {{candidate}} + + template <typename T> void f2(T) noexcept(T::throws); // expected-note {{candidate}} + template <typename T> void f2(T, int = 0) noexcept(T::sworht); // expected-note {{candidate}} + + void test() { + f1(0); // expected-error {{ambiguous}} + f2(0); // expected-error {{ambiguous}} + } +} + +struct Exc1 { char c[4]; }; +struct Exc2 { double x, y, z; }; +struct Base { + virtual void f() noexcept; // expected-note {{overridden}} +}; +template<typename T> struct Derived : Base { + void f() noexcept (sizeof(T) == 4); // expected-error {{is more lax}} + void g() noexcept (T::error); +}; + +Derived<Exc1> d1; // ok +Derived<Exc2> d2; // expected-note {{in instantiation of}} diff --git a/test/Tooling/clang-check-args.cpp b/test/Tooling/clang-check-args.cpp new file mode 100644 index 0000000..a14fc7b --- /dev/null +++ b/test/Tooling/clang-check-args.cpp @@ -0,0 +1,8 @@ +// RUN: clang-check . "%s" -- -c 2>&1 | FileCheck %s + +// CHECK: C++ requires +invalid; + +// FIXME: JSON doesn't like path separator '\', on Win32 hosts. +// FIXME: clang-check doesn't like gcc driver on cygming. +// XFAIL: cygwin,mingw32,win32 |