diff options
author | rdivacky <rdivacky@FreeBSD.org> | 2010-01-23 11:10:26 +0000 |
---|---|---|
committer | rdivacky <rdivacky@FreeBSD.org> | 2010-01-23 11:10:26 +0000 |
commit | 2fce988e86bc01829142e4362d4eff1af0925147 (patch) | |
tree | c69d3f4f13d508570bb5257a6aea735f88bdf09c /test/SemaCXX | |
parent | a3fa5c7f1b5e2ba4d6ec033dc0e2376326b05824 (diff) | |
download | FreeBSD-src-2fce988e86bc01829142e4362d4eff1af0925147.zip FreeBSD-src-2fce988e86bc01829142e4362d4eff1af0925147.tar.gz |
Update clang to r94309.
Diffstat (limited to 'test/SemaCXX')
-rw-r--r-- | test/SemaCXX/access-control-check.cpp | 7 | ||||
-rw-r--r-- | test/SemaCXX/anonymous-union.cpp | 10 | ||||
-rw-r--r-- | test/SemaCXX/enum.cpp | 11 | ||||
-rw-r--r-- | test/SemaCXX/new-delete.cpp | 2 | ||||
-rw-r--r-- | test/SemaCXX/overload-call.cpp | 14 | ||||
-rw-r--r-- | test/SemaCXX/unused.cpp | 9 | ||||
-rw-r--r-- | test/SemaCXX/virtual-override.cpp | 58 | ||||
-rw-r--r-- | test/SemaCXX/warn-unreachable.cpp | 76 |
8 files changed, 181 insertions, 6 deletions
diff --git a/test/SemaCXX/access-control-check.cpp b/test/SemaCXX/access-control-check.cpp index e6e261c..cf2d191 100644 --- a/test/SemaCXX/access-control-check.cpp +++ b/test/SemaCXX/access-control-check.cpp @@ -5,12 +5,11 @@ class M { }; class P { - int iP; - int PPR(); + int iP; // expected-note {{declared private here}} + int PPR(); // expected-note {{declared private here}} }; class N : M,P { N() {} - // FIXME. No access violation is reported in method call or member access. - int PR() { return iP + PPR(); } + int PR() { return iP + PPR(); } // expected-error 2 {{access to private member of 'class P'}} }; diff --git a/test/SemaCXX/anonymous-union.cpp b/test/SemaCXX/anonymous-union.cpp index 374241c..0590db2 100644 --- a/test/SemaCXX/anonymous-union.cpp +++ b/test/SemaCXX/anonymous-union.cpp @@ -111,3 +111,13 @@ struct BadMembers { // <rdar://problem/6481130> typedef union { }; // expected-error{{declaration does not declare anything}} + +// <rdar://problem/7562438> +typedef struct objc_module *Foo ; + +typedef struct _s { + union { + int a; + int Foo; + }; +} s, *ps; diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp index f1b02f5..47ae06a 100644 --- a/test/SemaCXX/enum.cpp +++ b/test/SemaCXX/enum.cpp @@ -56,3 +56,14 @@ namespace test1 { enum enum4 { v4 = __LONG_MAX__ * 2UL }; int test4[is_same<__typeof(+v4), unsigned long>::value]; } + +// PR6061 +namespace PR6061 { + struct A { enum { id }; }; + struct B { enum { id }; }; + + struct C : public A, public B + { + enum { id }; + }; +} diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp index 0e0f630..b058fc1 100644 --- a/test/SemaCXX/new-delete.cpp +++ b/test/SemaCXX/new-delete.cpp @@ -65,7 +65,7 @@ void bad_news(int *ip) (void)new S(1); // expected-error {{no matching constructor}} (void)new S(1, 1); // expected-error {{call to constructor of 'struct S' is ambiguous}} (void)new const int; // expected-error {{default initialization of an object of const type 'int const'}} - (void)new float*(ip); // expected-error {{cannot initialize a value of type 'float *' with an lvalue of type 'int *'}} + (void)new float*(ip); // expected-error {{cannot initialize a new value of type 'float *' with an lvalue of type 'int *'}} // Undefined, but clang should reject it directly. (void)new int[-1]; // expected-error {{array size is negative}} (void)new int[*(S*)0]; // expected-error {{array size expression must have integral or enumerated type, not 'struct S'}} diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp index d20bf23..12dc5da 100644 --- a/test/SemaCXX/overload-call.cpp +++ b/test/SemaCXX/overload-call.cpp @@ -333,3 +333,17 @@ namespace test2 { inline bool operator!=(const qrgb666 &v) const { return !(*this == v); } }; } + +// PR 6117 +namespace test3 { + struct Base {}; + struct Incomplete; + + void foo(Base *); // expected-note 2 {{cannot convert argument of incomplete type}} + void foo(Base &); // expected-note 2 {{cannot convert argument of incomplete type}} + + void test(Incomplete *P) { + foo(P); // expected-error {{no matching function for call to 'foo'}} + foo(*P); // expected-error {{no matching function for call to 'foo'}} + } +} diff --git a/test/SemaCXX/unused.cpp b/test/SemaCXX/unused.cpp index 6fd1081..88783ce 100644 --- a/test/SemaCXX/unused.cpp +++ b/test/SemaCXX/unused.cpp @@ -13,3 +13,12 @@ APSInt& APSInt::operator=(const APSInt &RHS) { APInt::operator=(RHS); return *this; } + +template<typename T> +struct X { + X(); +}; + +void test() { + X<int>(); +} diff --git a/test/SemaCXX/virtual-override.cpp b/test/SemaCXX/virtual-override.cpp index 4fdac85..5e1e9b0 100644 --- a/test/SemaCXX/virtual-override.cpp +++ b/test/SemaCXX/virtual-override.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s +// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s -std=c++0x namespace T1 { class A { @@ -197,3 +197,59 @@ namespace PR5920 { virtual Derived<int>* Method(); }; } + +// Look through template types and typedefs to see whether return types are +// pointers or references. +namespace PR6110 { + class Base {}; + class Derived : public Base {}; + + typedef Base* BaseP; + typedef Derived* DerivedP; + + class X { virtual BaseP f(); }; + class X1 : public X { virtual DerivedP f(); }; + + template <typename T> class Y { virtual T f(); }; + template <typename T1, typename T> class Y1 : public Y<T> { virtual T1 f(); }; + Y1<Derived*, Base*> y; +} + +namespace T10 { + struct A { }; + struct B : A { }; + + struct C { + virtual A&& f(); + }; + + struct D : C { + virtual B&& f(); + }; +}; + +namespace T11 { + struct A { }; + struct B : A { }; + + struct C { + virtual A& f(); // expected-note {{overridden virtual function is here}} + }; + + struct D : C { + virtual B&& f(); // expected-error {{virtual function 'f' has a different return type ('struct T11::B &&') than the function it overrides (which has return type 'struct T11::A &')}} + }; +}; + +namespace T12 { + struct A { }; + struct B : A { }; + + struct C { + virtual A&& f(); // expected-note {{overridden virtual function is here}} + }; + + struct D : C { + virtual B& f(); // expected-error {{virtual function 'f' has a different return type ('struct T12::B &') than the function it overrides (which has return type 'struct T12::A &&')}} + }; +}; diff --git a/test/SemaCXX/warn-unreachable.cpp b/test/SemaCXX/warn-unreachable.cpp new file mode 100644 index 0000000..a7ed91d --- /dev/null +++ b/test/SemaCXX/warn-unreachable.cpp @@ -0,0 +1,76 @@ +// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value + +int &halt() __attribute__((noreturn)); +int &live(); +int dead(); +int liveti() throw(int); +int (*livetip)() throw(int); + +int test1() { + try { + live(); + } catch (int i) { + live(); + } + return 1; +} + +void test2() { + try { + live(); + } catch (int i) { + live(); + } + try { + liveti(); + } catch (int i) { + live(); + } + try { + livetip(); + } catch (int i) { + live(); + } + throw 1; + dead(); // expected-warning {{will never be executed}} +} + + +void test3() { + halt() + --; // expected-warning {{will never be executed}} + halt() + ? // expected-warning {{will never be executed}} + dead() : dead(); + live(), + float // expected-warning {{will never be executed}} + (halt()); +} + +void test4() { + struct S { + int mem; + } s; + S &foor(); + halt(), foor() + .mem; // expected-warning {{will never be executed}} +} + +void test5() { + struct S { + int mem; + } s; + S &foor() __attribute__((noreturn)); + foor() + .mem; // expected-warning {{will never be executed}} +} + +void test6() { + struct S { + ~S() { } + S(int i) { } + }; + live(), + S // expected-warning {{will never be executed}} + (halt()); +} |