diff options
Diffstat (limited to 'test/SemaCXX')
-rw-r--r-- | test/SemaCXX/alignof-sizeof-reference.cpp | 9 | ||||
-rw-r--r-- | test/SemaCXX/attr-cxx0x.cpp | 36 | ||||
-rw-r--r-- | test/SemaCXX/attr-sentinel.cpp | 6 | ||||
-rw-r--r-- | test/SemaCXX/class-layout.cpp | 17 | ||||
-rw-r--r-- | test/SemaCXX/class.cpp | 8 | ||||
-rw-r--r-- | test/SemaCXX/condition.cpp | 8 | ||||
-rw-r--r-- | test/SemaCXX/converting-constructor.cpp | 7 | ||||
-rw-r--r-- | test/SemaCXX/implicit-int.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/member-pointers-2.cpp | 36 | ||||
-rw-r--r-- | test/SemaCXX/nested-name-spec.cpp | 3 | ||||
-rw-r--r-- | test/SemaCXX/new-delete.cpp | 12 | ||||
-rw-r--r-- | test/SemaCXX/pseudo-destructors.cpp | 9 | ||||
-rw-r--r-- | test/SemaCXX/qual-id-test.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/reinterpret-cast.cpp | 10 | ||||
-rw-r--r-- | test/SemaCXX/switch-0x.cpp | 11 | ||||
-rw-r--r-- | test/SemaCXX/switch.cpp | 27 | ||||
-rw-r--r-- | test/SemaCXX/typedef-redecl.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/using-directive.cpp | 10 |
18 files changed, 207 insertions, 10 deletions
diff --git a/test/SemaCXX/alignof-sizeof-reference.cpp b/test/SemaCXX/alignof-sizeof-reference.cpp new file mode 100644 index 0000000..27d98ab --- /dev/null +++ b/test/SemaCXX/alignof-sizeof-reference.cpp @@ -0,0 +1,9 @@ +// RUN: clang-cc -std=c++0x -fsyntax-only -verify %s + +struct s0; // expected-note {{forward declaration}} +char ar[sizeof(s0&)]; // expected-error {{invalid application of 'sizeof' to an incomplete type}} +void test() { + char &r = ar[0]; + static_assert(alignof(r) == 1, "bad alignment"); + static_assert(sizeof(r) == 1, "bad size"); +} diff --git a/test/SemaCXX/attr-cxx0x.cpp b/test/SemaCXX/attr-cxx0x.cpp new file mode 100644 index 0000000..da52d33 --- /dev/null +++ b/test/SemaCXX/attr-cxx0x.cpp @@ -0,0 +1,36 @@ +// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s + +int final_fail [[final]]; //expected-error {{'final' attribute only applies to virtual method or class types}} + +struct [[final]] final_base { }; // expected-note {{struct final_base declared here}} +struct final_child : final_base { }; // expected-error {{derivation from 'final' struct final_base}} + +struct final_member { virtual void quux [[final]] (); }; // expected-note {{overridden virtual function is here}} +struct final_override : final_member { virtual void quux (); }; // expected-error {{declaration of 'quux' overrides a 'final' function}} + +int align_illegal [[align(3)]]; //expected-error {{requested alignment is not a power of 2}} +char align_big [[align(int)]]; +int align_small [[align(1)]]; +int align_multiple [[align(1), align(8), align(1)]]; + +struct align_member { + int member [[align(8)]]; +}; + +static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong"); +static_assert(alignof(align_small) == alignof(int), "j's alignment is wrong"); +static_assert(alignof(align_multiple) == 8, "l's alignment is wrong"); +static_assert(alignof(align_member) == 8, "quuux's alignment is wrong"); +static_assert(sizeof(align_member) == 8, "quuux's size is wrong"); + +int bc_fail [[base_check]]; // expected-error {{'base_check' attribute only applies to class types}} +int hiding_fail [[hiding]]; // expected-error {{'hiding' attribute only applies to member types}} +int override_fail [[override]]; // expected-error {{'override' attribute only applies to virtual method types}} + +struct base { + virtual void function(); + virtual void other_function(); +}; + +struct [[base_check, base_check]] bc : base { // expected-error {{'base_check' attribute cannot be repeated}} +};
\ No newline at end of file diff --git a/test/SemaCXX/attr-sentinel.cpp b/test/SemaCXX/attr-sentinel.cpp new file mode 100644 index 0000000..0293a5d --- /dev/null +++ b/test/SemaCXX/attr-sentinel.cpp @@ -0,0 +1,6 @@ +// RUN: clang-cc -fsyntax-only -verify %s +void f(int, ...) __attribute__((sentinel)); + +void g() { + f(1, 2, __null); +} diff --git a/test/SemaCXX/class-layout.cpp b/test/SemaCXX/class-layout.cpp index 56f41bf..b597172 100644 --- a/test/SemaCXX/class-layout.cpp +++ b/test/SemaCXX/class-layout.cpp @@ -47,3 +47,20 @@ struct G { G(); }; struct H : G { }; SA(6, sizeof(H) == 1); + +// PR5580 +namespace PR5580 { + +class A { bool iv0 : 1; }; +SA(7, sizeof(A) == 1); + +class B : A { bool iv0 : 1; }; +SA(8, sizeof(B) == 2); + +struct C { bool iv0 : 1; }; +SA(9, sizeof(C) == 1); + +struct D : C { bool iv0 : 1; }; +SA(10, sizeof(D) == 2); + +} diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp index d2a8114..2637f32 100644 --- a/test/SemaCXX/class.cpp +++ b/test/SemaCXX/class.cpp @@ -110,3 +110,11 @@ struct C4 { void f(); // expected-note{{previous declaration is here}} int f; // expected-error{{duplicate member 'f'}} }; + +// PR5415 - don't hang! +struct S +{ + void f(); // expected-note 1 {{previous declaration}} + void S::f() {} // expected-error {{class member cannot be redeclared}} expected-note {{previous declaration}} expected-note {{previous definition}} + void f() {} // expected-error {{class member cannot be redeclared}} expected-error {{redefinition}} +}; diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp index 7c9cee5..b2645d4 100644 --- a/test/SemaCXX/condition.cpp +++ b/test/SemaCXX/condition.cpp @@ -33,3 +33,11 @@ void test() { for (; int x=0; ) { int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}} switch (int x=0) { default: int x; } // expected-error {{redefinition of 'x'}} expected-note {{previous definition is here}} } + +int* get_int_ptr(); + +void test2() { + float *ip; + if (int *ip = ip) { + } +} diff --git a/test/SemaCXX/converting-constructor.cpp b/test/SemaCXX/converting-constructor.cpp index 59b793e..3f347b4 100644 --- a/test/SemaCXX/converting-constructor.cpp +++ b/test/SemaCXX/converting-constructor.cpp @@ -38,3 +38,10 @@ void explicit_constructor(short s) { FromShortExplicitly fse1(s); FromShortExplicitly fse2 = s; // expected-error{{error: cannot initialize 'fse2' with an lvalue of type 'short'}} } + +// PR5519 +struct X1 { X1(const char&); }; +void x1(X1); +void y1() { + x1(1); +} diff --git a/test/SemaCXX/implicit-int.cpp b/test/SemaCXX/implicit-int.cpp index 7230305..6fa8dd3 100644 --- a/test/SemaCXX/implicit-int.cpp +++ b/test/SemaCXX/implicit-int.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only -verify -fms-extensions=0 %s +// RUN: clang-cc -fsyntax-only -verify %s x; // expected-error{{C++ requires a type specifier for all declarations}} diff --git a/test/SemaCXX/member-pointers-2.cpp b/test/SemaCXX/member-pointers-2.cpp new file mode 100644 index 0000000..fea1d74 --- /dev/null +++ b/test/SemaCXX/member-pointers-2.cpp @@ -0,0 +1,36 @@ +// RUN: clang-cc -emit-llvm-only %s + +// Tests that Sema properly creates member-access expressions for +// these instead of bare FieldDecls. + +struct Foo { + int myvalue; + + // We have to override these to get something with an lvalue result. + int &operator++(int); + int &operator--(int); +}; + +struct Test0 { + Foo memfoo; + int memint; + int memarr[10]; + Test0 *memptr; + struct MemClass { int a; } memstruct; + int &memfun(); + + void test() { + int *p; + p = &Test0::memfoo++; + p = &Test0::memfoo--; + p = &Test0::memarr[1]; + p = &Test0::memptr->memint; + p = &Test0::memstruct.a; + p = &Test0::memfun(); + } +}; + +void test0() { + Test0 mytest; + mytest.test(); +} diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp index 721758f..83c72417 100644 --- a/test/SemaCXX/nested-name-spec.cpp +++ b/test/SemaCXX/nested-name-spec.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only -std=c++98 -verify -fms-extensions=0 %s +// RUN: clang-cc -fsyntax-only -std=c++98 -verify %s namespace A { struct C { static int cx; @@ -87,7 +87,6 @@ void f3() { N::x = 0; // expected-error {{expected a class or namespace}} { int A; A::ax = 0; } { typedef int A; A::ax = 0; } // expected-error{{expected a class or namespace}} - { int A(); A::ax = 0; } { typedef A::C A; A::ax = 0; } // expected-error {{no member named 'ax'}} { typedef A::C A; A::cx = 0; } } diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp index ededfc0..f2fe0a7 100644 --- a/test/SemaCXX/new-delete.cpp +++ b/test/SemaCXX/new-delete.cpp @@ -190,3 +190,15 @@ class X9 { void f(X9 *x9) { delete x9; // expected-error {{no suitable member 'operator delete' in 'X9'}} } + +struct X10 { + virtual ~X10(); +}; + +struct X11 : X10 { // expected-error {{no suitable member 'operator delete' in 'X11'}} + void operator delete(void*, int); // expected-note {{'operator delete' declared here}} +}; + +void f() { + X11 x11; // expected-note {{implicit default destructor for 'struct X11' first required here}} +} diff --git a/test/SemaCXX/pseudo-destructors.cpp b/test/SemaCXX/pseudo-destructors.cpp index 0850c44..8f69def 100644 --- a/test/SemaCXX/pseudo-destructors.cpp +++ b/test/SemaCXX/pseudo-destructors.cpp @@ -38,3 +38,12 @@ typedef int Integer; void destroy_without_call(int *ip) { ip->~Integer; // expected-error{{called immediately}} } + +// PR5530 +namespace N1 { + class X0 { }; +} + +void test_X0(N1::X0 &x0) { + x0.~X0(); +} diff --git a/test/SemaCXX/qual-id-test.cpp b/test/SemaCXX/qual-id-test.cpp index ecb6aa9..02e6999 100644 --- a/test/SemaCXX/qual-id-test.cpp +++ b/test/SemaCXX/qual-id-test.cpp @@ -48,7 +48,7 @@ namespace C a.A::sub::x(); a.A::B::base::x(); - a.bad::x(); // expected-error{{type 'struct bad' is not a direct or virtual base of ''struct A::sub''}} + a.bad::x(); // expected-error{{type 'struct bad' is not a direct or virtual base of ''A::sub''}} a->foo(); a->member::foo(); @@ -69,7 +69,7 @@ namespace C a->A::sub::x(); a->A::B::base::x(); - a->bad::x(); // expected-error{{type 'struct bad' is not a direct or virtual base of ''struct A::sub''}} + a->bad::x(); // expected-error{{type 'struct bad' is not a direct or virtual base of ''A::sub''}} (*a)->foo(); (*a)->member::foo(); diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp index be960a3..bfe8887 100644 --- a/test/SemaCXX/reinterpret-cast.cpp +++ b/test/SemaCXX/reinterpret-cast.cpp @@ -1,5 +1,7 @@ // RUN: clang-cc -fsyntax-only -verify %s +#include <stdint.h> + enum test { testval = 1 }; struct structure { int m; }; typedef void (*fnptr)(); @@ -20,11 +22,11 @@ void self_conversion() void integral_conversion() { void *vp = reinterpret_cast<void*>(testval); - long l = reinterpret_cast<long>(vp); - (void)reinterpret_cast<float*>(l); - fnptr fnp = reinterpret_cast<fnptr>(l); + intptr_t i = reinterpret_cast<intptr_t>(vp); + (void)reinterpret_cast<float*>(i); + fnptr fnp = reinterpret_cast<fnptr>(i); (void)reinterpret_cast<char>(fnp); // expected-error {{cast from pointer to smaller type 'char' loses information}} - (void)reinterpret_cast<long>(fnp); + (void)reinterpret_cast<intptr_t>(fnp); } void pointer_conversion() diff --git a/test/SemaCXX/switch-0x.cpp b/test/SemaCXX/switch-0x.cpp new file mode 100644 index 0000000..c1f6bd9 --- /dev/null +++ b/test/SemaCXX/switch-0x.cpp @@ -0,0 +1,11 @@ +// RUN: clang-cc -fsyntax-only -verify -std=c++0x %s + +// PR5518 +struct A { + explicit operator int(); // expected-note{{conversion to integral type}} +}; + +void x() { + switch(A()) { // expected-error{{explicit conversion to}} + } +} diff --git a/test/SemaCXX/switch.cpp b/test/SemaCXX/switch.cpp index b22adb7..003d5b8 100644 --- a/test/SemaCXX/switch.cpp +++ b/test/SemaCXX/switch.cpp @@ -13,3 +13,30 @@ void test() { break; } } + +// PR5518 +struct A { + operator int(); // expected-note{{conversion to integral type}} +}; + +void x() { + switch(A()) { + } +} + +enum E { e1, e2 }; +struct B : A { + operator E() const; // expected-note{{conversion to enumeration type}} +}; + +void x2() { + switch (B()) { // expected-error{{multiple conversions}} + } +} + +struct C; // expected-note{{forward declaration}} + +void x3(C &c) { + switch (c) { // expected-error{{incomplete class type}} + } +} diff --git a/test/SemaCXX/typedef-redecl.cpp b/test/SemaCXX/typedef-redecl.cpp index 85944a6..e38f474 100644 --- a/test/SemaCXX/typedef-redecl.cpp +++ b/test/SemaCXX/typedef-redecl.cpp @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only -verify -fms-extensions=0 %s +// RUN: clang-cc -fsyntax-only -verify %s typedef int INT; typedef INT REALLY_INT; // expected-note {{previous definition is here}} typedef REALLY_INT REALLY_REALLY_INT; diff --git a/test/SemaCXX/using-directive.cpp b/test/SemaCXX/using-directive.cpp index 3b67c7a..51f347d 100644 --- a/test/SemaCXX/using-directive.cpp +++ b/test/SemaCXX/using-directive.cpp @@ -102,3 +102,13 @@ namespace FuncHidesTagAmbiguity { (void)X(); // expected-error{{reference to 'X' is ambiguous}} } } + +// PR5479 +namespace Aliased { + void inAliased(); +} +namespace Alias = Aliased; +using namespace Alias; +void testAlias() { + inAliased(); +} |