summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-03-21 10:50:08 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-03-21 10:50:08 +0000
commit1e255aab650a7fa2047fd953cae65b12215280af (patch)
tree508d4388db78f87d35bf26a0400b4b03bc4c1f13 /test/SemaCXX
parent1033b7c1e32962948b01a25145829f17bc70a8de (diff)
downloadFreeBSD-src-1e255aab650a7fa2047fd953cae65b12215280af.zip
FreeBSD-src-1e255aab650a7fa2047fd953cae65b12215280af.tar.gz
Update clang to r99115.
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/access-base-class.cpp5
-rw-r--r--test/SemaCXX/class.cpp18
-rw-r--r--test/SemaCXX/condition.cpp2
-rw-r--r--test/SemaCXX/conditional-expr.cpp6
-rw-r--r--test/SemaCXX/warn-shadow.cpp44
-rw-r--r--test/SemaCXX/warn-sign-compare.cpp72
6 files changed, 141 insertions, 6 deletions
diff --git a/test/SemaCXX/access-base-class.cpp b/test/SemaCXX/access-base-class.cpp
index eeb5f1c..25fd9e5 100644
--- a/test/SemaCXX/access-base-class.cpp
+++ b/test/SemaCXX/access-base-class.cpp
@@ -63,13 +63,14 @@ namespace T6 {
class A {};
- class B : private A { // expected-note {{declared private here}}
+ class B : private A { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
void f(C* c);
};
class C : public B {
void f(C *c) {
- A* a = c; // expected-error {{cannot cast 'T6::C' to its private base class 'T6::A'}}
+ A* a = c; // expected-error {{cannot cast 'T6::C' to its private base class 'T6::A'}} \
+ // expected-error {{'A' is a private member of 'T6::A'}}
}
};
diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index 743983c..508ca4d 100644
--- a/test/SemaCXX/class.cpp
+++ b/test/SemaCXX/class.cpp
@@ -118,3 +118,21 @@ struct S
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}}
};
+
+// Don't crash on this bogus code.
+namespace pr6629 {
+ // TODO: most of these errors are spurious
+ template<class T1, class T2> struct foo :
+ bogus<foo<T1,T2> > // expected-error {{unknown template name 'bogus'}} \
+ // BOGUS expected-error {{expected '{' after base class list}} \
+ // BOGUS expected-error {{expected ';' after struct}} \
+ // BOGUS expected-error {{expected unqualified-id}} \
+ { };
+
+ template<> struct foo<unknown,unknown> { // why isn't there an error here?
+ template <typename U1, typename U2> struct bar {
+ typedef bar type;
+ static const int value = 0;
+ };
+ };
+}
diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp
index b3e862d..daa86f6 100644
--- a/test/SemaCXX/condition.cpp
+++ b/test/SemaCXX/condition.cpp
@@ -17,7 +17,7 @@ void test() {
switch (s) {} // expected-error {{statement requires expression of integer type ('struct S' invalid)}}
while (struct S {} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{no viable conversion}} expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}} expected-note{{candidate constructor (the implicit copy constructor)}}
- while (struct {} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{no viable conversion}} expected-error {{value of type 'struct <anonymous>' is not contextually convertible to 'bool'}} expected-note{{candidate constructor (the implicit copy constructor)}}
+ while (struct {} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{no viable conversion}} expected-error {{not contextually convertible to 'bool'}} expected-note{{candidate constructor (the implicit copy constructor)}}
switch (enum {E} x=0) ; // expected-error {{types may not be defined in conditions}} expected-error {{cannot initialize}} \
// expected-warning{{enumeration value 'E' not handled in switch}}
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index 4fcb0bb..accc8db 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -154,8 +154,8 @@ void test()
i1 = i1 ? i1 : ir1;
int *pi1 = i1 ? &i1 : 0;
pi1 = i1 ? 0 : &i1;
- i1 = i1 ? i1 : EVal; // expected-warning {{operands of ? are integers of different signs}} ??
- i1 = i1 ? EVal : i1; // expected-warning {{operands of ? are integers of different signs}} ??
+ i1 = i1 ? i1 : EVal;
+ i1 = i1 ? EVal : i1;
d1 = i1 ? 'c' : 4.0;
d1 = i1 ? 4.0 : 'c';
Base *pb = i1 ? (Base*)0 : (Derived*)0;
@@ -191,7 +191,7 @@ void test()
test0 = test0 ? (short) 10 : test0;
test0 = test0 ? EVal : test0;
- test0 = test0 ? EVal : (int) test0; // expected-warning {{operands of ? are integers of different signs}}
+ test0 = test0 ? EVal : (int) test0;
// Note the thing that this does not test: since DR446, various situations
// *must* create a separate temporary copy of class objects. This can only
diff --git a/test/SemaCXX/warn-shadow.cpp b/test/SemaCXX/warn-shadow.cpp
new file mode 100644
index 0000000..509c344
--- /dev/null
+++ b/test/SemaCXX/warn-shadow.cpp
@@ -0,0 +1,44 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wshadow %s
+
+namespace {
+ int i; // expected-note {{previous declaration is here}}
+}
+
+namespace one {
+namespace two {
+ int j; // expected-note {{previous declaration is here}}
+}
+}
+
+namespace xx {
+ int m;
+}
+namespace yy {
+ int m;
+}
+
+using namespace one::two;
+using namespace xx;
+using namespace yy;
+
+void foo() {
+ int i; // expected-warning {{declaration shadows a variable in namespace '<anonymous>'}}
+ int j; // expected-warning {{declaration shadows a variable in namespace 'one::two'}}
+ int m;
+}
+
+class A {
+ static int data; // expected-note {{previous declaration}}
+ int field; // expected-note {{previous declaration}}
+
+ void test() {
+ char *field; // expected-warning {{declaration shadows a field of 'A'}}
+ char *data; // expected-warning {{declaration shadows a static data member of 'A'}}
+ }
+};
+
+// TODO: this should warn, <rdar://problem/5018057>
+class B : A {
+ int data;
+ static int field;
+};
diff --git a/test/SemaCXX/warn-sign-compare.cpp b/test/SemaCXX/warn-sign-compare.cpp
new file mode 100644
index 0000000..3042bfd
--- /dev/null
+++ b/test/SemaCXX/warn-sign-compare.cpp
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wsign-compare %s
+
+// NOTE: When a 'enumeral mismatch' warning is implemented then expect several
+// of the following cases to be impacted.
+
+// namespace for anonymous enums tests
+namespace test1 {
+ enum { A };
+ enum { B = -1 };
+
+ template <typename T> struct Foo {
+ enum { C };
+ enum { D = ~0U };
+ };
+
+ enum { E = ~0U };
+
+ void doit_anonymous( int i ) {
+ int a1 = 1 ? i : A;
+ int a2 = 1 ? A : i;
+
+ int b1 = 1 ? i : B;
+ int b2 = 1 ? B : i;
+
+ int c1 = 1 ? i : Foo<bool>::C;
+ int c2 = 1 ? Foo<bool>::C : i;
+
+ int d1 = 1 ? i : Foo<bool>::D; // expected-warning {{operands of ? are integers of different signs}}
+ int d2 = 1 ? Foo<bool>::D : i; // expected-warning {{operands of ? are integers of different signs}}
+ int d3 = 1 ? B : Foo<bool>::D; // expected-warning {{operands of ? are integers of different signs}}
+ int d4 = 1 ? Foo<bool>::D : B; // expected-warning {{operands of ? are integers of different signs}}
+
+ int e1 = 1 ? i : E; // expected-warning {{operands of ? are integers of different signs}}
+ int e2 = 1 ? E : i; // expected-warning {{operands of ? are integers of different signs}}
+ int e3 = 1 ? E : B; // expected-warning {{operands of ? are integers of different signs}}
+ int e4 = 1 ? B : E; // expected-warning {{operands of ? are integers of different signs}}
+ }
+}
+
+// namespace for named enums tests
+namespace test2 {
+ enum Named1 { A };
+ enum Named2 { B = -1 };
+
+ template <typename T> struct Foo {
+ enum Named3 { C };
+ enum Named4 { D = ~0U };
+ };
+
+ enum Named5 { E = ~0U };
+
+ void doit_anonymous( int i ) {
+ int a1 = 1 ? i : A;
+ int a2 = 1 ? A : i;
+
+ int b1 = 1 ? i : B;
+ int b2 = 1 ? B : i;
+
+ int c1 = 1 ? i : Foo<bool>::C;
+ int c2 = 1 ? Foo<bool>::C : i;
+
+ int d1 = 1 ? i : Foo<bool>::D; // expected-warning {{operands of ? are integers of different signs}}
+ int d2 = 1 ? Foo<bool>::D : i; // expected-warning {{operands of ? are integers of different signs}}
+ int d3 = 1 ? B : Foo<bool>::D; // expected-warning {{operands of ? are integers of different signs}}
+ int d4 = 1 ? Foo<bool>::D : B; // expected-warning {{operands of ? are integers of different signs}}
+
+ int e1 = 1 ? i : E; // expected-warning {{operands of ? are integers of different signs}}
+ int e2 = 1 ? E : i; // expected-warning {{operands of ? are integers of different signs}}
+ int e3 = 1 ? E : B; // expected-warning {{operands of ? are integers of different signs}}
+ int e4 = 1 ? B : E; // expected-warning {{operands of ? are integers of different signs}}
+ }
+}
OpenPOWER on IntegriCloud