summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-04-02 08:55:10 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-04-02 08:55:10 +0000
commit07b2cfcdb817cc0790420f159a313d61e7241cb9 (patch)
treed374cdca417e76f1bf101f139dba2db1d10ee8f7 /test/SemaCXX
parent1e255aab650a7fa2047fd953cae65b12215280af (diff)
downloadFreeBSD-src-07b2cfcdb817cc0790420f159a313d61e7241cb9.zip
FreeBSD-src-07b2cfcdb817cc0790420f159a313d61e7241cb9.tar.gz
Update clang to r100181.
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/PR6618.cpp13
-rw-r--r--test/SemaCXX/class-base-member-init.cpp44
-rw-r--r--test/SemaCXX/class-layout.cpp7
-rw-r--r--test/SemaCXX/conditional-expr.cpp18
-rw-r--r--test/SemaCXX/destructor.cpp5
-rw-r--r--test/SemaCXX/exception-spec.cpp6
-rw-r--r--test/SemaCXX/invalid-member-expr.cpp18
-rw-r--r--test/SemaCXX/namespace-alias.cpp10
-rw-r--r--test/SemaCXX/namespace.cpp22
-rw-r--r--test/SemaCXX/nested-name-spec.cpp2
-rw-r--r--test/SemaCXX/new-delete-predefined-decl-2.cpp13
-rw-r--r--test/SemaCXX/qual-id-test.cpp9
-rw-r--r--test/SemaCXX/static-cast.cpp4
-rw-r--r--test/SemaCXX/warn-reorder-ctor-initialization.cpp12
14 files changed, 170 insertions, 13 deletions
diff --git a/test/SemaCXX/PR6618.cpp b/test/SemaCXX/PR6618.cpp
new file mode 100644
index 0000000..10d4dc8
--- /dev/null
+++ b/test/SemaCXX/PR6618.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+class bar; // expected-note {{forward declaration of 'bar'}}
+struct zed {
+ bar g; // expected-error {{field has incomplete type}}
+};
+class baz {
+ zed h;
+};
+void f() {
+ enum {
+ e = sizeof(baz)
+ };
+}
diff --git a/test/SemaCXX/class-base-member-init.cpp b/test/SemaCXX/class-base-member-init.cpp
index 1c6e790..7095d92 100644
--- a/test/SemaCXX/class-base-member-init.cpp
+++ b/test/SemaCXX/class-base-member-init.cpp
@@ -6,14 +6,48 @@ public:
};
struct D : S {
- D() : b1(0), b2(1), b1(0), S(), S() {} // expected-error {{multiple initializations given for non-static member 'b1'}} \
- // expected-note {{previous initialization is here}} \
- // expected-error {{multiple initializations given for base 'S'}} \
- // expected-note {{previous initialization is here}}
-
+ D() :
+ b1(0), // expected-note {{previous initialization is here}}
+ b2(1),
+ b1(0), // expected-error {{multiple initializations given for non-static member 'b1'}}
+ S(), // expected-note {{previous initialization is here}}
+ S() // expected-error {{multiple initializations given for base 'S'}}
+ {}
int b1;
int b2;
+};
+struct A {
+ struct {
+ int a;
+ int b;
+ };
+ A();
};
+A::A() : a(10), b(20) { }
+
+namespace Test1 {
+ template<typename T> struct A {};
+ template<typename T> struct B : A<T> {
+
+ B() : A<T>(), // expected-note {{previous initialization is here}}
+ A<T>() { } // expected-error {{multiple initializations given for base 'A<T>'}}
+ };
+}
+
+namespace Test2 {
+ template<typename T> struct A : T {
+ A() : T(), // expected-note {{previous initialization is here}}
+ T() { } // expected-error {{multiple initializations given for base 'T'}}
+ };
+}
+namespace Test3 {
+ template<typename T> struct A {
+ T t;
+
+ A() : t(1), // expected-note {{previous initialization is here}}
+ t(2) { } // expected-error {{multiple initializations given for non-static member 't'}}
+ };
+}
diff --git a/test/SemaCXX/class-layout.cpp b/test/SemaCXX/class-layout.cpp
index 2b8d1d3..f3c75f4 100644
--- a/test/SemaCXX/class-layout.cpp
+++ b/test/SemaCXX/class-layout.cpp
@@ -48,6 +48,13 @@ struct H : G { };
SA(6, sizeof(H) == 1);
+struct I {
+ char b;
+ int a;
+} __attribute__((packed));
+
+SA(6_1, sizeof(I) == 5);
+
// PR5580
namespace PR5580 {
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index accc8db..e2a966bd 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -7,7 +7,8 @@
struct ToBool { explicit operator bool(); };
struct B;
-struct A { A(); A(const B&); }; // expected-note 2 {{candidate constructor}}
+struct A { A(); A(const B&); }; // expected-note 2 {{candidate constructor}} \
+ // expected-note 2 {{candidate is the implicit copy constructor}}
struct B { operator A() const; }; // expected-note 2 {{candidate function}}
struct I { operator int(); };
struct J { operator I(); };
@@ -197,3 +198,18 @@ void test()
// *must* create a separate temporary copy of class objects. This can only
// be properly tested at runtime, though.
}
+
+namespace PR6595 {
+ struct String {
+ String(const char *);
+ operator const char*() const;
+ };
+
+ void f(bool Cond, String S) {
+ (void)(Cond? S : "");
+ (void)(Cond? "" : S);
+ const char a[1] = {'a'};
+ (void)(Cond? S : a);
+ (void)(Cond? a : S);
+ }
+}
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp
index 7010d2e..ae3dc86 100644
--- a/test/SemaCXX/destructor.cpp
+++ b/test/SemaCXX/destructor.cpp
@@ -78,3 +78,8 @@ namespace PR6421 {
}
};
}
+
+namespace PR6709 {
+ template<class T> class X { T v; ~X() { ++*v; } };
+ void a(X<int> x) {}
+}
diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp
index 782cf83..498611e 100644
--- a/test/SemaCXX/exception-spec.cpp
+++ b/test/SemaCXX/exception-spec.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fexceptions -fms-extensions %s
// Straight from the standard:
// Plain function with spec
@@ -50,7 +50,7 @@ void r4() throw(int, float);
void r4() throw(float, int);
void r5() throw(int); // expected-note {{previous declaration}}
-void r5(); // expected-error {{exception specification in declaration does not match}}
+void r5(); // expected-warning {{missing exception specification}}
void r6() throw(...); // expected-note {{previous declaration}}
void r6() throw(int); // expected-error {{exception specification in declaration does not match}}
@@ -170,7 +170,7 @@ void fnptrs()
// Member function stuff
struct Str1 { void f() throw(int); }; // expected-note {{previous declaration}}
-void Str1::f() // expected-error {{does not match previous declaration}}
+void Str1::f() // expected-warning {{missing exception specification}}
{
}
diff --git a/test/SemaCXX/invalid-member-expr.cpp b/test/SemaCXX/invalid-member-expr.cpp
index 7b17afb..7307a47 100644
--- a/test/SemaCXX/invalid-member-expr.cpp
+++ b/test/SemaCXX/invalid-member-expr.cpp
@@ -19,3 +19,21 @@ void test2() {
x->operator; // expected-error{{missing type specifier after 'operator'}}
x->operator typedef; // expected-error{{missing type specifier after 'operator'}}
}
+
+// PR6327
+namespace test3 {
+ template <class A, class B> struct pair {};
+
+ void test0() {
+ pair<int, int> z = minmax({}); // expected-error {{expected expression}}
+ }
+
+ struct string {
+ class iterator {};
+ };
+
+ void test1() {
+ string s;
+ string::iterator i = s.foo(); // expected-error {{no member named 'foo'}}
+ }
+}
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index 06114c3..3ea1ccf 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-namespace N { };
+namespace N { struct X { }; };
namespace A = N;
@@ -83,3 +83,11 @@ namespace K {
KC::func(); // expected-error {{undeclared identifier 'KC'}}
}
}
+
+// PR6341
+namespace A = N;
+namespace N { }
+namespace A = N;
+
+A::X nx;
+
diff --git a/test/SemaCXX/namespace.cpp b/test/SemaCXX/namespace.cpp
index 2a9d31f..d47b707 100644
--- a/test/SemaCXX/namespace.cpp
+++ b/test/SemaCXX/namespace.cpp
@@ -68,3 +68,25 @@ namespace foo {
static foo::x test1; // ok
static foo::X test2; // typo: expected-error {{no type named 'X' in}}
+
+namespace PR6620 {
+ namespace numeric {
+ namespace op {
+ struct greater {};
+ }
+ namespace {
+ extern op::greater const greater;
+ }
+ }
+
+ namespace numeric {
+ namespace {
+ op::greater const greater = op::greater();
+ }
+
+ template<typename T, typename U>
+ int f(T& l, U& r)
+ { numeric::greater(l, r); }
+
+ }
+}
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp
index 8657c0d..9a611c3 100644
--- a/test/SemaCXX/nested-name-spec.cpp
+++ b/test/SemaCXX/nested-name-spec.cpp
@@ -64,7 +64,7 @@ void f2() {
A::C c1;
struct A::C c2;
struct S : public A::C {};
-struct A::undef; // expected-error {{'undef' does not name a tag member in the specified scope}}
+struct A::undef; // expected-error {{no struct named 'undef' in namespace 'A'}}
namespace A2 {
typedef int INT;
diff --git a/test/SemaCXX/new-delete-predefined-decl-2.cpp b/test/SemaCXX/new-delete-predefined-decl-2.cpp
new file mode 100644
index 0000000..981476d
--- /dev/null
+++ b/test/SemaCXX/new-delete-predefined-decl-2.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -DQUALIFIED -fsyntax-only -verify %s
+
+// PR5904
+void f0(int *ptr) {
+#ifndef QUALIFIED
+ operator delete(ptr);
+#endif
+}
+
+void f1(int *ptr) {
+ ::operator delete[](ptr);
+}
diff --git a/test/SemaCXX/qual-id-test.cpp b/test/SemaCXX/qual-id-test.cpp
index 54d41b8..4846e72 100644
--- a/test/SemaCXX/qual-id-test.cpp
+++ b/test/SemaCXX/qual-id-test.cpp
@@ -138,3 +138,12 @@ struct a {
a a;
int a::sa = a.a; // expected-error {{invalid use of nonstatic data member 'a'}}
+
+
+namespace PR6645 {
+ typedef int foo;
+ namespace Inner {
+ typedef int PR6645::foo; // expected-error{{typedef declarator cannot be qualified}} \
+ // expected-error{{definition or redeclaration of 'foo' not in a namespace enclosing 'PR6645'}}
+ }
+}
diff --git a/test/SemaCXX/static-cast.cpp b/test/SemaCXX/static-cast.cpp
index 2630278..a5dd7e2 100644
--- a/test/SemaCXX/static-cast.cpp
+++ b/test/SemaCXX/static-cast.cpp
@@ -60,7 +60,7 @@ void t_529_2()
(void)static_cast<A*>((H*)0); // expected-error {{ambiguous conversion}}
(void)static_cast<int>((int*)0); // expected-error {{static_cast from 'int *' to 'int' is not allowed}}
(void)static_cast<A**>((B**)0); // expected-error {{static_cast from 'B **' to 'A **' is not allowed}}
- (void)static_cast<char&>(i); // expected-error {{non-const lvalue reference to type 'char' cannot be initialized with a value of type 'int'}}
+ (void)static_cast<char&>(i); // expected-error {{non-const lvalue reference to type 'char' cannot bind to a value of unrelated type 'int'}}
}
// Anything to void
@@ -91,7 +91,7 @@ void t_529_5_8()
(void)static_cast<H*>((A*)0); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
(void)static_cast<H&>(*((A*)0)); // expected-error {{ambiguous cast from base 'A' to derived 'H':\n struct A -> struct B -> struct G1 -> struct H\n struct A -> struct B -> struct G2 -> struct H}}
(void)static_cast<E*>((B*)0); // expected-error {{static_cast from 'B *' to 'E *' is not allowed}}
- (void)static_cast<E&>(*((B*)0)); // expected-error {{non-const lvalue reference to type 'E' cannot be initialized with a value of type 'B'}}
+ (void)static_cast<E&>(*((B*)0)); // expected-error {{non-const lvalue reference to type 'E' cannot bind to a value of unrelated type 'B'}}
// TODO: Test inaccessible base in context where it's accessible, i.e.
// member function and friend.
diff --git a/test/SemaCXX/warn-reorder-ctor-initialization.cpp b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
index 2634202..f419156 100644
--- a/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -87,3 +87,15 @@ class Anon3 {
union {int a,b;};
Anon3() : b(1) {}
};
+
+namespace T1 {
+
+struct S1 { };
+struct S2: virtual S1 { };
+struct S3 { };
+
+struct S4: virtual S3, S2 {
+ S4() : S2(), // expected-warning {{base class 'T1::S2' will be initialized after}}
+ S3() { }; // expected-note {{base 'T1::S3'}}
+};
+}
OpenPOWER on IntegriCloud