aboutsummaryrefslogtreecommitdiff
path: root/test/CXX/class
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/class')
-rw-r--r--test/CXX/class/class.mem/p2.cpp31
-rw-r--r--test/CXX/class/class.mem/p8-0x-pedantic.cpp14
-rw-r--r--test/CXX/class/class.mem/p8-0x.cpp2
-rw-r--r--test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp17
-rw-r--r--test/CXX/class/class.union/p1.cpp34
-rw-r--r--test/CXX/class/p1-0x.cpp4
6 files changed, 58 insertions, 44 deletions
diff --git a/test/CXX/class/class.mem/p2.cpp b/test/CXX/class/class.mem/p2.cpp
new file mode 100644
index 0000000000000..09040d859c809
--- /dev/null
+++ b/test/CXX/class/class.mem/p2.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++11 [class.mem]p2:
+// A class is considered a completely-defined object type (or
+// complete type) at the closing } of the class-specifier. Within
+// the class member-specification, the class is regarded as complete
+// within function bodies, default arguments,
+// exception-specifications, and brace-or-equal-initializers for
+// non-static data members (including such things in nested classes).
+// Otherwise it is regarded as incomplete within its own class
+// member-specification.
+
+namespace test0 {
+ struct A { // expected-note {{definition of 'test0::A' is not complete until the closing '}'}}
+ A x; // expected-error {{field has incomplete type 'test0::A'}}
+ };
+}
+
+namespace test1 {
+ template <class T> struct A {
+ A<int> x; // expected-error {{implicit instantiation of template 'test1::A<int>' within its own definition}}
+ };
+}
+
+namespace test2 {
+ template <class T> struct A;
+ template <> struct A<int> {};
+ template <class T> struct A {
+ A<int> x;
+ };
+}
diff --git a/test/CXX/class/class.mem/p8-0x-pedantic.cpp b/test/CXX/class/class.mem/p8-0x-pedantic.cpp
deleted file mode 100644
index a4b775c191d88..0000000000000
--- a/test/CXX/class/class.mem/p8-0x-pedantic.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++0x -pedantic -verify %s
-
-namespace inline_extension {
- struct Base1 {
- virtual void f() {}
- };
-
- struct B : Base1 {
- virtual void f() override {} // expected-warning {{'override' keyword only allowed in declarations, allowed as an extension}}
- virtual void g() final {} // expected-warning {{'final' keyword only allowed in declarations, allowed as an extension}}
- virtual void h() new {} // expected-warning {{'new' keyword only allowed in declarations, allowed as an extension}}
- };
-}
-
diff --git a/test/CXX/class/class.mem/p8-0x.cpp b/test/CXX/class/class.mem/p8-0x.cpp
index bf1b4c177bf87..836ebad48ee15 100644
--- a/test/CXX/class/class.mem/p8-0x.cpp
+++ b/test/CXX/class/class.mem/p8-0x.cpp
@@ -5,7 +5,6 @@ struct Base1 {
};
struct A : Base1 {
- virtual void f() new new; // expected-error {{class member already marked 'new'}}
virtual void g() override override; // expected-error {{class member already marked 'override'}}
virtual void h() final final; // expected-error {{class member already marked 'final'}}
};
@@ -34,7 +33,6 @@ namespace inline_extension {
};
struct A : Base1 {
- virtual void f() new new {} // expected-error {{class member already marked 'new'}}
virtual void g() override override {} // expected-error {{class member already marked 'override'}}
virtual void h() final final {} // expected-error {{class member already marked 'final'}}
};
diff --git a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp
index c81e4ef1b1b87..9116e7146f812 100644
--- a/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp
+++ b/test/CXX/class/class.mfct/class.mfct.non-static/p3.cpp
@@ -35,17 +35,22 @@ namespace test1 {
struct A {
void foo(Opaque1); // expected-note {{candidate}}
void foo(Opaque2); // expected-note {{candidate}}
- void test();
};
struct B : A {
-
+ void test();
};
- void A::test() {
- B::foo(Opaque1());
- B::foo(Opaque2());
- B::foo(Opaque3()); // expected-error {{no matching member function}}
+ struct C1 : A { };
+ struct C2 : B { };
+
+ void B::test() {
+ A::foo(Opaque1());
+ A::foo(Opaque2());
+ A::foo(Opaque3()); // expected-error {{no matching member function}}
+
+ C1::foo(Opaque1()); // expected-error {{call to non-static member function without an object argument}}
+ C2::foo(Opaque1()); // expected-error {{call to non-static member function without an object argument}}
}
}
diff --git a/test/CXX/class/class.union/p1.cpp b/test/CXX/class/class.union/p1.cpp
index b5dd4dfd705db..011185fb49e48 100644
--- a/test/CXX/class/class.union/p1.cpp
+++ b/test/CXX/class/class.union/p1.cpp
@@ -7,30 +7,30 @@ class Okay {
};
class Virtual {
- virtual void foo() { abort(); } // expected-note 3 {{because type 'Virtual' has a virtual member function}}
+ virtual void foo() { abort(); } // expected-note 4 {{because type 'Virtual' has a virtual member function}}
};
-class VirtualBase : virtual Okay { // expected-note 3 {{because type 'VirtualBase' has a virtual base class}}
+class VirtualBase : virtual Okay { // expected-note 4 {{because type 'VirtualBase' has a virtual base class}}
};
class Ctor {
- Ctor() { abort(); } // expected-note 3 {{because type 'Ctor' has a user-declared constructor}}
+ Ctor() { abort(); } // expected-note 4 {{because type 'Ctor' has a user-declared constructor}}
};
class Ctor2 {
Ctor2(); // expected-note 3 {{because type 'Ctor2' has a user-declared constructor}}
};
class CopyCtor {
- CopyCtor(CopyCtor &cc) { abort(); } // expected-note 3 {{because type 'CopyCtor' has a user-declared copy constructor}}
+ CopyCtor(CopyCtor &cc) { abort(); } // expected-note 4 {{because type 'CopyCtor' has a user-declared copy constructor}}
};
// FIXME: this should eventually trigger on the operator's declaration line
-class CopyAssign { // expected-note 3 {{because type 'CopyAssign' has a user-declared copy assignment operator}}
+class CopyAssign { // expected-note 4 {{because type 'CopyAssign' has a user-declared copy assignment operator}}
CopyAssign& operator=(CopyAssign& CA) { abort(); }
};
class Dtor {
- ~Dtor() { abort(); } // expected-note 3 {{because type 'Dtor' has a user-declared destructor}}
+ ~Dtor() { abort(); } // expected-note 4 {{because type 'Dtor' has a user-declared destructor}}
};
union U1 {
@@ -100,23 +100,21 @@ union U5 {
template <class A, class B> struct Either {
bool tag;
- union {
+ union { // expected-note 6 {{in instantiation of member class}}
A a;
- B b;
+ B b; // expected-error 6 {{non-trivial}}
};
- Either(A& a) : tag(true), a(a) {}
- Either(B& b) : tag(false), b(b) {}
+ Either(const A& a) : tag(true), a(a) {}
+ Either(const B& b) : tag(false), b(b) {}
};
-/* FIXME: this should work, but crashes in template code.
void fred() {
- Either<int,Virtual> virt(0);
- Either<int,VirtualBase> vbase(0);
- Either<int,Ctor> ctor(0);
- Either<int,CopyCtor> copyctor(0);
- Either<int,CopyAssign> copyassign(0);
- Either<int,Dtor> dtor(0);
+ Either<int,Virtual> virt(0); // expected-note {{in instantiation of template}}
+ Either<int,VirtualBase> vbase(0); // expected-note {{in instantiation of template}}
+ Either<int,Ctor> ctor(0); // expected-note {{in instantiation of template}}
+ Either<int,CopyCtor> copyctor(0); // expected-note {{in instantiation of template}}
+ Either<int,CopyAssign> copyassign(0); // expected-note {{in instantiation of template}}
+ Either<int,Dtor> dtor(0); // expected-note {{in instantiation of template}}
Either<int,Okay> okay(0);
}
- */
diff --git a/test/CXX/class/p1-0x.cpp b/test/CXX/class/p1-0x.cpp
index 5851de6cc3951..e677dec4caf1f 100644
--- a/test/CXX/class/p1-0x.cpp
+++ b/test/CXX/class/p1-0x.cpp
@@ -2,9 +2,5 @@
namespace Test1 {
class A final { };
-class B explicit { };
-class C final explicit { };
-class D final final { }; // expected-error {{class already marked 'final'}}
-class E explicit explicit { }; // expected-error {{class already marked 'explicit'}}
}