summaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-07-04 13:58:54 +0000
committerEd Schouten <ed@FreeBSD.org>2009-07-04 13:58:54 +0000
commit5362a71c02e7d448a8ce98cf00c47e353fba5d04 (patch)
tree8ddfe382e1c6d590dc240e76f7cd45cea5c78e24 /test/SemaCXX
parent4ebdf5c4f587daef4e0be499802eac3a7a49bf2f (diff)
Notes
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/class-base-member-init.cpp19
-rw-r--r--test/SemaCXX/constructor-initializer.cpp39
-rw-r--r--test/SemaCXX/decltype-overloaded-functions.cpp12
-rw-r--r--test/SemaCXX/exception-spec.cpp30
-rw-r--r--test/SemaCXX/member-pointer.cpp2
5 files changed, 100 insertions, 2 deletions
diff --git a/test/SemaCXX/class-base-member-init.cpp b/test/SemaCXX/class-base-member-init.cpp
new file mode 100644
index 000000000000..c38c3d3337e7
--- /dev/null
+++ b/test/SemaCXX/class-base-member-init.cpp
@@ -0,0 +1,19 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+class S {
+public:
+ S ();
+};
+
+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 'class S'}} \
+ // expected-note {{previous initialization is here}}
+
+ int b1;
+ int b2;
+
+};
+
+
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index d0c978a80d15..a180d907f1b7 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -1,6 +1,7 @@
// RUN: clang-cc -fsyntax-only -verify %s
class A {
int m;
+ A() : A::m(17) { } // expected-error {{member initializer 'm' does not name a non-static data member or base class}}
};
class B : public A {
@@ -54,3 +55,41 @@ class H : A {
H::H() : A(10) { }
+
+class X {};
+class Y {};
+
+struct S : Y, virtual X {
+ S ();
+};
+
+struct Z : S {
+ Z() : S(), X(), E() {} // expected-error {{type 'class E' is not a direct or virtual base of 'Z'}}
+};
+
+class U {
+ union { int a; char* p; };
+ union { int b; double d; };
+
+ U() : a(1), p(0), d(1.0) {} // expected-error {{multiple initializations given for non-static member 'p'}} \
+ // expected-note {{previous initialization is here}}
+};
+
+struct V {};
+struct Base {};
+struct Base1 {};
+
+struct Derived : Base, Base1, virtual V {
+ Derived ();
+};
+
+struct Current : Derived {
+ int Derived;
+ Current() : Derived(1), ::Derived(),
+ ::Derived::Base(), // expected-error {{type '::Derived::Base' is not a direct or virtual base of 'Current'}}
+ Derived::Base1(), // expected-error {{type 'Derived::Base1' is not a direct or virtual base of 'Current'}}
+ Derived::V(),
+ ::NonExisting(), // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
+ INT::NonExisting() {} // expected-error {{expected a class or namespace}} \
+ // expected-error {{member initializer 'NonExisting' does not name a non-static data member or}}
+};
diff --git a/test/SemaCXX/decltype-overloaded-functions.cpp b/test/SemaCXX/decltype-overloaded-functions.cpp
new file mode 100644
index 000000000000..4c5349b85868
--- /dev/null
+++ b/test/SemaCXX/decltype-overloaded-functions.cpp
@@ -0,0 +1,12 @@
+// RUN: clang-cc -fsyntax-only -verify %s -std=c++0x
+
+void f();
+void f(int);
+decltype(f) a; // expected-error{{can't determine the declared type of an overloaded function}}
+
+template<typename T> struct S {
+ decltype(T::f) * f; // expected-error{{can't determine the declared type of an overloaded function}}
+};
+
+struct K { void f(); void f(int); };
+S<K> b; // expected-note{{in instantiation of template class 'struct S<struct K>' requested here}}
diff --git a/test/SemaCXX/exception-spec.cpp b/test/SemaCXX/exception-spec.cpp
index ea02aac4915f..5eba26e70c6f 100644
--- a/test/SemaCXX/exception-spec.cpp
+++ b/test/SemaCXX/exception-spec.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-cc -fsyntax-only -verify %s
+// RUN: clang-cc -fsyntax-only -verify -fms-extensions %s
// Straight from the standard:
// Plain function with spec
@@ -33,3 +33,31 @@ void ic2() throw(Incomplete); // expected-error {{incomplete type 'struct Incomp
void ic3() throw(void*);
void ic4() throw(Incomplete*); // expected-error {{pointer to incomplete type 'struct Incomplete' is not allowed in exception specification}}
void ic5() throw(Incomplete&); // expected-error {{reference to incomplete type 'struct Incomplete' is not allowed in exception specification}}
+
+// Redeclarations
+typedef int INT;
+void r1() throw(int);
+void r1() throw(int);
+
+void r2() throw(int);
+void r2() throw(INT);
+
+// throw-any spec and no spec at all are semantically equivalent
+void r3();
+void r3() throw(...);
+
+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 r6() throw(...); // expected-note {{previous declaration}}
+void r6() throw(int); // expected-error {{exception specification in declaration does not match}}
+
+void r7() throw(int); // expected-note {{previous declaration}}
+void r7() throw(float); // expected-error {{exception specification in declaration does not match}}
+
+// Top-level const doesn't matter.
+void r8() throw(int);
+void r8() throw(const int);
diff --git a/test/SemaCXX/member-pointer.cpp b/test/SemaCXX/member-pointer.cpp
index d2df5eb317a0..3b106d5576fe 100644
--- a/test/SemaCXX/member-pointer.cpp
+++ b/test/SemaCXX/member-pointer.cpp
@@ -16,7 +16,7 @@ int B::*pbi; // expected-error {{expected a class or namespace}} \
// expected-error{{does not point into a class}}
int C::*pci; // expected-error {{'pci' does not point into a class}}
void A::*pdv; // expected-error {{'pdv' declared as a member pointer to void}}
-int& A::*pdr; // expected-error {{'pdr' declared as a pointer to a reference}}
+int& A::*pdr; // expected-error {{'pdr' declared as a member pointer to a reference}}
void f() {
// This requires tentative parsing.