summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorrdivacky <rdivacky@FreeBSD.org>2010-07-13 17:21:42 +0000
committerrdivacky <rdivacky@FreeBSD.org>2010-07-13 17:21:42 +0000
commit1928da94b55683957759d5c5ff4593a118773394 (patch)
tree48b44512b5db8ced345df4a1a56b5065cf2a14d9 /test/SemaCXX
parent53992adde3eda3ccf9da63bc7e45673f043de18f (diff)
downloadFreeBSD-src-1928da94b55683957759d5c5ff4593a118773394.zip
FreeBSD-src-1928da94b55683957759d5c5ff4593a118773394.tar.gz
Update clang to r108243.
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/abstract.cpp18
-rw-r--r--test/SemaCXX/access-base-class.cpp2
-rw-r--r--test/SemaCXX/ambig-user-defined-conversions.cpp3
-rw-r--r--test/SemaCXX/attr-regparm.cpp14
-rw-r--r--test/SemaCXX/blocks-1.cpp10
-rw-r--r--test/SemaCXX/class-layout.cpp31
-rw-r--r--test/SemaCXX/class.cpp6
-rw-r--r--test/SemaCXX/compare.cpp8
-rw-r--r--test/SemaCXX/conditional-expr.cpp31
-rw-r--r--test/SemaCXX/constructor-initializer.cpp17
-rw-r--r--test/SemaCXX/conversion.cpp45
-rw-r--r--test/SemaCXX/crash-8124080.cpp21
-rw-r--r--test/SemaCXX/destructor.cpp24
-rw-r--r--test/SemaCXX/empty-class-layout.cpp60
-rw-r--r--test/SemaCXX/enum.cpp8
-rw-r--r--test/SemaCXX/exception-spec-no-exceptions.cpp32
-rw-r--r--test/SemaCXX/friend.cpp17
-rw-r--r--test/SemaCXX/function-type-qual.cpp9
-rw-r--r--test/SemaCXX/implicit-member-functions.cpp11
-rw-r--r--test/SemaCXX/init-priority-attr.cpp36
-rw-r--r--test/SemaCXX/instantiate-blocks.cpp19
-rw-r--r--test/SemaCXX/member-expr.cpp29
-rw-r--r--test/SemaCXX/new-array-size-conv.cpp27
-rw-r--r--test/SemaCXX/new-delete.cpp49
-rw-r--r--test/SemaCXX/overload-call.cpp30
-rw-r--r--test/SemaCXX/overloaded-builtin-operators.cpp16
-rw-r--r--test/SemaCXX/overloaded-operator.cpp9
-rw-r--r--test/SemaCXX/pseudo-destructors.cpp12
-rw-r--r--test/SemaCXX/reinterpret-cast.cpp12
-rw-r--r--test/SemaCXX/rval-references.cpp7
-rw-r--r--test/SemaCXX/typedef-redecl.cpp6
-rw-r--r--test/SemaCXX/using-directive.cpp5
-rw-r--r--test/SemaCXX/vector.cpp30
-rw-r--r--test/SemaCXX/warn-self-comparisons.cpp5
-rw-r--r--test/SemaCXX/warn-unreachable.cpp2
-rw-r--r--test/SemaCXX/warn-unused-variables.cpp2
-rw-r--r--test/SemaCXX/warn_false_to_pointer.cpp9
-rw-r--r--test/SemaCXX/wchar_t.cpp5
38 files changed, 663 insertions, 14 deletions
diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp
index 3e61cc3..f64fda4 100644
--- a/test/SemaCXX/abstract.cpp
+++ b/test/SemaCXX/abstract.cpp
@@ -168,3 +168,21 @@ namespace PureImplicit {
struct D : C {};
D y;
}
+
+namespace test1 {
+ struct A {
+ virtual void foo() = 0;
+ };
+
+ struct B : A {
+ using A::foo;
+ };
+
+ struct C : B {
+ void foo();
+ };
+
+ void test() {
+ C c;
+ }
+}
diff --git a/test/SemaCXX/access-base-class.cpp b/test/SemaCXX/access-base-class.cpp
index 8551690..f676e19 100644
--- a/test/SemaCXX/access-base-class.cpp
+++ b/test/SemaCXX/access-base-class.cpp
@@ -61,7 +61,7 @@ namespace T5 {
namespace T6 {
class C;
- class A {};
+ class A {}; // expected-note{{member is declared here}}
class B : private A { // expected-note {{declared private here}} expected-note {{constrained by private inheritance here}}
void f(C* c);
diff --git a/test/SemaCXX/ambig-user-defined-conversions.cpp b/test/SemaCXX/ambig-user-defined-conversions.cpp
index 7f67674..9811859 100644
--- a/test/SemaCXX/ambig-user-defined-conversions.cpp
+++ b/test/SemaCXX/ambig-user-defined-conversions.cpp
@@ -17,7 +17,8 @@ namespace test0 {
void func(const char ci, const B b); // expected-note {{candidate function}}
void func(const B b, const int ci); // expected-note {{candidate function}}
- const int Test1() {
+ const int Test1() { // expected-warning{{type qualifier on return type has no effect}}
+
func(b1, f()); // expected-error {{call to 'func' is ambiguous}}
return f(); // expected-error {{conversion from 'test0::B' to 'int const' is ambiguous}}
}
diff --git a/test/SemaCXX/attr-regparm.cpp b/test/SemaCXX/attr-regparm.cpp
new file mode 100644
index 0000000..b98631a
--- /dev/null
+++ b/test/SemaCXX/attr-regparm.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR7025
+struct X0 {
+ void __attribute__((regparm(3))) f0();
+ void __attribute__((regparm(3))) f1();
+ void __attribute__((regparm(3))) f2(); // expected-note{{previous declaration is here}}
+ void f3(); // expected-note{{previous declaration is here}}
+};
+
+void X0::f0() { }
+void __attribute__((regparm(3))) X0::f1() { }
+void __attribute__((regparm(2))) X0::f2() { } // expected-error{{function declared with with regparm(2) attribute was previously declared with the regparm(3) attribute}}
+void __attribute__((regparm(2))) X0::f3() { } // expected-error{{function declared with with regparm(2) attribute was previously declared without the regparm attribute}}
diff --git a/test/SemaCXX/blocks-1.cpp b/test/SemaCXX/blocks-1.cpp
index d93997a..29de1e6 100644
--- a/test/SemaCXX/blocks-1.cpp
+++ b/test/SemaCXX/blocks-1.cpp
@@ -33,3 +33,13 @@ int main (int argc, const char * argv[]) {
return 0;
}
+
+namespace rdar8134521 {
+ void foo() {
+ int (^P)(int) = reinterpret_cast<int(^)(int)>(1);
+ P = (int(^)(int))(1);
+
+ P = reinterpret_cast<int(^)(int)>((void*)1);
+ P = (int(^)(int))((void*)1);
+ }
+}
diff --git a/test/SemaCXX/class-layout.cpp b/test/SemaCXX/class-layout.cpp
index f3c75f4..d81944a 100644
--- a/test/SemaCXX/class-layout.cpp
+++ b/test/SemaCXX/class-layout.cpp
@@ -71,3 +71,34 @@ struct D : C { bool iv0 : 1; };
SA(10, sizeof(D) == 2);
}
+
+namespace Test1 {
+
+// Test that we don't assert on this hierarchy.
+struct A { };
+struct B : A { virtual void b(); };
+class C : virtual A { int c; };
+struct D : virtual B { };
+struct E : C, virtual D { };
+class F : virtual E { };
+struct G : virtual E, F { };
+
+SA(0, sizeof(G) == 24);
+
+}
+
+namespace Test2 {
+
+// Test that this somewhat complex class structure is laid out correctly.
+struct A { };
+struct B : A { virtual void b(); };
+struct C : virtual B { };
+struct D : virtual A { };
+struct E : virtual B, D { };
+struct F : E, virtual C { };
+struct G : virtual F, A { };
+struct H { G g; };
+
+SA(0, sizeof(H) == 24);
+
+}
diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index b5cecbc..9d9508b 100644
--- a/test/SemaCXX/class.cpp
+++ b/test/SemaCXX/class.cpp
@@ -159,3 +159,9 @@ namespace PR7196 {
}
};
}
+
+namespace rdar8066414 {
+ class C {
+ C() {}
+ } // expected-error{{expected ';' after class}}
+}
diff --git a/test/SemaCXX/compare.cpp b/test/SemaCXX/compare.cpp
index 4790347..ebecc06 100644
--- a/test/SemaCXX/compare.cpp
+++ b/test/SemaCXX/compare.cpp
@@ -198,3 +198,11 @@ int test1(int i) {
enum en { zero };
return i > zero;
}
+
+enum E { e };
+void test2(int i, void *vp) {
+ if (test1 == vp) { } // expected-warning{{equality comparison between function pointer and void pointer}}
+ if (test1 == e) { } // expected-error{{comparison between pointer and integer}}
+ if (vp < 0) { }
+ if (test1 < e) { } // expected-error{{comparison between pointer and integer}}
+}
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index a09ff2b..f37ccc8 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -199,17 +199,24 @@ void test()
}
namespace PR6595 {
+ struct OtherString {
+ OtherString();
+ OtherString(const char*);
+ };
+
struct String {
String(const char *);
+ String(const OtherString&);
operator const char*() const;
};
- void f(bool Cond, String S) {
+ void f(bool Cond, String S, OtherString OS) {
(void)(Cond? S : "");
(void)(Cond? "" : S);
const char a[1] = {'a'};
(void)(Cond? S : a);
(void)(Cond? a : S);
+ (void)(Cond? OS : S);
}
}
@@ -275,3 +282,25 @@ namespace rdar7998817 {
: X());
}
}
+
+namespace PR7598 {
+ enum Enum {
+ v = 1,
+ };
+
+ const Enum g() { // expected-warning{{type qualifier on return type has no effect}}
+ return v;
+ }
+
+ const volatile Enum g2() { // expected-warning{{'const volatile' type qualifiers on return type have no effect}}
+ return v;
+ }
+
+ void f() {
+ const Enum v2 = v;
+ Enum e = false ? g() : v;
+ Enum e2 = false ? v2 : v;
+ Enum e3 = false ? g2() : v;
+ }
+
+}
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index 8e9e133..cf309f5 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -204,3 +204,20 @@ C f(C c) {
}
}
+
+// Don't build implicit initializers for anonymous union fields when we already
+// have an explicit initializer for another field in the union.
+namespace PR7402 {
+ struct S {
+ union {
+ void* ptr_;
+ struct { int i_; };
+ };
+
+ template <typename T> S(T) : ptr_(0) { }
+ };
+
+ void f() {
+ S s(3);
+ }
+}
diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp
new file mode 100644
index 0000000..f648943
--- /dev/null
+++ b/test/SemaCXX/conversion.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -Wconversion -verify %s
+
+typedef signed char int8_t;
+typedef signed short int16_t;
+typedef signed int int32_t;
+typedef signed long int64_t;
+
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned int uint32_t;
+typedef unsigned long uint64_t;
+
+// <rdar://problem/7909130>
+namespace test0 {
+ int32_t test1_positive(char *I, char *E) {
+ return (E - I); // expected-warning {{implicit conversion loses integer precision}}
+ }
+
+ int32_t test1_negative(char *I, char *E) {
+ return static_cast<int32_t>(E - I);
+ }
+
+ uint32_t test2_positive(uint64_t x) {
+ return x; // expected-warning {{implicit conversion loses integer precision}}
+ }
+
+ uint32_t test2_negative(uint64_t x) {
+ return (uint32_t) x;
+ }
+}
+
+namespace test1 {
+ uint64_t test1(int x, unsigned y) {
+ return sizeof(x == y);
+ }
+
+ uint64_t test2(int x, unsigned y) {
+ return __alignof(x == y);
+ }
+
+ void * const foo();
+ bool test2(void *p) {
+ return p == foo();
+ }
+}
diff --git a/test/SemaCXX/crash-8124080.cpp b/test/SemaCXX/crash-8124080.cpp
new file mode 100644
index 0000000..78a0315
--- /dev/null
+++ b/test/SemaCXX/crash-8124080.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// <rdar://problem/8124080>
+template<typename _Alloc> class allocator;
+template<class _CharT> struct char_traits;
+template<typename _CharT, typename _Traits = char_traits<_CharT>,
+ typename _Alloc = allocator<_CharT> >
+class basic_string;
+template<typename _CharT, typename _Traits, typename _Alloc>
+const typename basic_string<_CharT, _Traits, _Alloc>::size_type
+basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_max_size // expected-error{{no member named '_Rep' in 'basic_string<_CharT, _Traits, _Alloc>'}}
+ = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
+
+// PR7118
+template<typename T>
+class Foo {
+ class Bar;
+ void f() {
+ Bar i;
+ }
+};
diff --git a/test/SemaCXX/destructor.cpp b/test/SemaCXX/destructor.cpp
index ae3dc86..4f6c76b 100644
--- a/test/SemaCXX/destructor.cpp
+++ b/test/SemaCXX/destructor.cpp
@@ -19,7 +19,9 @@ struct D {
// expected-error{{type qualifier is not allowed on this function}} \
// expected-error{{destructor cannot be declared 'static'}} \
// expected-error{{destructor cannot have any parameters}} \
- // expected-error{{destructor cannot be variadic}}
+ // expected-error{{destructor cannot be variadic}} \
+ // expected-error{{destructor cannot have a return type}} \
+ // expected-error{{'const' qualifier is not allowed on a destructor}}
};
struct D2 {
@@ -83,3 +85,23 @@ namespace PR6709 {
template<class T> class X { T v; ~X() { ++*v; } };
void a(X<int> x) {}
}
+
+struct X0 { virtual ~X0() throw(); };
+struct X1 : public X0 { };
+
+// Make sure we instantiate operator deletes when building a virtual
+// destructor.
+namespace test6 {
+ template <class T> class A {
+ public:
+ void *operator new(__SIZE_TYPE__);
+ void operator delete(void *p) {
+ T::deleteIt(p); // expected-error {{type 'int' cannot be used prior to '::'}}
+ }
+
+ virtual ~A() {} // expected-note {{in instantiation of member function 'test6::A<int>::operator delete' requested here}}
+ };
+
+ class B : A<int> { B(); };
+ B::B() {}
+}
diff --git a/test/SemaCXX/empty-class-layout.cpp b/test/SemaCXX/empty-class-layout.cpp
index 27f5040..0b46bf0 100644
--- a/test/SemaCXX/empty-class-layout.cpp
+++ b/test/SemaCXX/empty-class-layout.cpp
@@ -84,3 +84,63 @@ class F : D, E { };
SA(0, sizeof(F) == 24);
}
+
+namespace Test2 {
+
+// Test that B::a isn't laid out at offset 0.
+struct Empty { };
+struct A : Empty { };
+struct B : Empty {
+ A a;
+};
+
+SA(0, sizeof(B) == 2);
+
+}
+
+namespace Test3 {
+
+// Test that B::a isn't laid out at offset 0.
+struct Empty { };
+struct A { Empty e; };
+struct B : Empty { A a; };
+SA(0, sizeof(B) == 2);
+
+}
+
+namespace Test4 {
+
+// Test that C::Empty isn't laid out at offset 0.
+struct Empty { };
+struct A : Empty { };
+struct B { A a; };
+struct C : B, Empty { };
+SA(0, sizeof(C) == 2);
+
+}
+
+namespace Test5 {
+
+// Test that B::Empty isn't laid out at offset 0.
+struct Empty { };
+struct Field : virtual Empty { };
+struct A {
+ Field f;
+};
+struct B : A, Empty { };
+SA(0, sizeof(B) == 16);
+
+}
+
+namespace Test6 {
+
+// Test that B::A isn't laid out at offset 0.
+struct Empty { };
+struct Field : virtual Empty { };
+struct A {
+ Field f;
+};
+struct B : Empty, A { };
+SA(0, sizeof(B) == 16);
+
+}
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
index bfb5784..0690ead 100644
--- a/test/SemaCXX/enum.cpp
+++ b/test/SemaCXX/enum.cpp
@@ -1,9 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only -pedantic -std=c++98 -verify -triple x86_64-apple-darwin %s
-enum E {
+enum E { // expected-note{{previous definition is here}}
Val1,
Val2
};
+enum E; // expected-warning{{redeclaration of already-defined enum 'E' is a GNU extension}}
+
int& enumerator_type(int);
float& enumerator_type(E);
@@ -79,3 +81,7 @@ namespace PR7051 {
e |= 1; // expected-error{{assigning to 'PR7051::E' from incompatible type 'int'}}
}
}
+
+// PR7466
+enum { }; // expected-warning{{declaration does not declare anything}}
+typedef enum { }; // expected-warning{{typedef requires a name}}
diff --git a/test/SemaCXX/exception-spec-no-exceptions.cpp b/test/SemaCXX/exception-spec-no-exceptions.cpp
new file mode 100644
index 0000000..1fe45b0
--- /dev/null
+++ b/test/SemaCXX/exception-spec-no-exceptions.cpp
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Note: this is intentionally -fno-exceptions, not just accidentally
+// so because that's the current -cc1 default.
+
+// PR7243: redeclarations
+namespace test0 {
+ void foo() throw(int);
+ void foo() throw();
+}
+
+// Overrides.
+namespace test1 {
+ struct A {
+ virtual void foo() throw();
+ };
+
+ struct B : A {
+ virtual void foo() throw(int);
+ };
+}
+
+// Calls from less permissive contexts. We don't actually do this
+// check, but if we did it should also be disabled under
+// -fno-exceptions.
+namespace test2 {
+ void foo() throw(int);
+ void bar() throw() {
+ foo();
+ }
+}
+
diff --git a/test/SemaCXX/friend.cpp b/test/SemaCXX/friend.cpp
index ffad0e2..65e0da7 100644
--- a/test/SemaCXX/friend.cpp
+++ b/test/SemaCXX/friend.cpp
@@ -44,6 +44,21 @@ namespace test2 {
// PR5134
namespace test3 {
class Foo {
- friend const int getInt(int inInt = 0);
+ friend const int getInt(int inInt = 0); // expected-warning{{'const' type qualifier on return type has no effect}}
+
+ };
+}
+
+namespace test4 {
+ class T4A {
+ friend class T4B;
+
+ public:
+ T4A(class T4B *);
+
+ protected:
+ T4B *mB; // error here
};
+
+ class T4B {};
}
diff --git a/test/SemaCXX/function-type-qual.cpp b/test/SemaCXX/function-type-qual.cpp
index be61f2b..8ebb506 100644
--- a/test/SemaCXX/function-type-qual.cpp
+++ b/test/SemaCXX/function-type-qual.cpp
@@ -1,15 +1,17 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
void f() const; // expected-error {{type qualifier is not allowed on this function}}
+void (*pf)() const; // expected-error {{type qualifier is not allowed on this function pointer}}
+void (&rf)() const = f; // expected-error {{type qualifier is not allowed on this function reference}}
typedef void cfn() const;
-cfn f2; // expected-error {{a qualified function type cannot be used to declare a nonmember function or a static member function}}
+cfn f2; // expected-error {{a qualified function type cannot be used to declare a nonmember function}}
class C {
void f() const;
cfn f2;
static void f3() const; // expected-error {{type qualifier is not allowed on this function}}
- static cfn f4; // expected-error {{a qualified function type cannot be used to declare a nonmember function or a static member function}}
+ static cfn f4; // expected-error {{a qualified function type cannot be used to declare a static member function}}
void m1() {
x = 0;
@@ -21,3 +23,6 @@ class C {
int x;
};
+
+void (C::*mpf)() const;
+cfn C::*mpg;
diff --git a/test/SemaCXX/implicit-member-functions.cpp b/test/SemaCXX/implicit-member-functions.cpp
index 79cc367..5333094 100644
--- a/test/SemaCXX/implicit-member-functions.cpp
+++ b/test/SemaCXX/implicit-member-functions.cpp
@@ -39,3 +39,14 @@ namespace PR6570 {
};
}
+
+namespace PR7594 {
+ // If the lazy declaration of special member functions is triggered
+ // in an out-of-line initializer, make sure the functions aren't in
+ // the initializer scope. This used to crash Clang:
+ struct C {
+ C();
+ static C *c;
+ };
+ C *C::c = new C();
+}
diff --git a/test/SemaCXX/init-priority-attr.cpp b/test/SemaCXX/init-priority-attr.cpp
new file mode 100644
index 0000000..6ea263d
--- /dev/null
+++ b/test/SemaCXX/init-priority-attr.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+class Two {
+private:
+ int i, j, k;
+public:
+ static int count;
+ Two( int ii, int jj ) { i = ii; j = jj; k = count++; };
+ Two( void ) { i = 0; j = 0; k = count++; };
+ int eye( void ) { return i; };
+ int jay( void ) { return j; };
+ int kay( void ) { return k; };
+};
+
+extern Two foo;
+extern Two goo;
+extern Two coo[];
+extern Two koo[];
+
+Two foo __attribute__((init_priority(101))) ( 5, 6 );
+
+Two goo __attribute__((init_priority(2,3))) ( 5, 6 ); // expected-error {{attribute requires 1 argument(s)}}
+
+Two coo[2] __attribute__((init_priority(3))); // expected-error {{init_priority attribute requires integer constant between 101 and 65535 inclusive}}
+
+Two koo[4] __attribute__((init_priority(1.13))); // expected-error {{'init_priority' attribute requires integer constant}}
+
+
+Two func() __attribute__((init_priority(1001))); // expected-error {{can only use ‘init_priority’ attribute on file-scope definitions of objects of class type}}
+
+int i __attribute__((init_priority(1001))); // expected-error {{can only use ‘init_priority’ attribute on file-scope definitions of objects of class type}}
+
+int main() {
+ Two foo __attribute__((init_priority(1001))); // expected-error {{can only use ‘init_priority’ attribute on file-scope definitions of objects of class type}}
+}
+
diff --git a/test/SemaCXX/instantiate-blocks.cpp b/test/SemaCXX/instantiate-blocks.cpp
new file mode 100644
index 0000000..a4001a7
--- /dev/null
+++ b/test/SemaCXX/instantiate-blocks.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fblocks -fsyntax-only -verify %s
+// rdar: // 6182276
+
+template <typename T, typename T1> void foo(T t, T1 r)
+{
+ T block_arg;
+ __block T1 byref_block_arg;
+
+ T1 (^block)(T) = ^ T1 (T arg) {
+ byref_block_arg = arg;
+ block_arg = arg; // expected-error {{variable is not assignable (missing __block type specifier)}}
+ return block_arg+arg; };
+}
+
+int main(void)
+{
+ foo(100, 'a'); // expected-note {{in instantiation of function template specialization 'foo<int, char>' requested here}}
+}
+
diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp
index 54a9593..6830c5f 100644
--- a/test/SemaCXX/member-expr.cpp
+++ b/test/SemaCXX/member-expr.cpp
@@ -72,3 +72,32 @@ namespace test4 {
y.f(17);
}
}
+
+namespace test5 {
+ struct A {
+ template <class T> void foo();
+ };
+
+ void test0(int x) {
+ x.A::foo<int>(); // expected-error {{'int' is not a structure or union}}
+ }
+
+ void test1(A *x) {
+ x.A::foo<int>(); // expected-error {{'test5::A *' is a pointer}}
+ }
+
+ void test2(A &x) {
+ x->A::foo<int>(); // expected-error {{'test5::A' is not a pointer}}
+ }
+}
+
+namespace PR7508 {
+ struct A {
+ struct CleanupScope {};
+ void PopCleanupBlock();
+ };
+
+ void foo(A &a) {
+ a.PopCleanupScope(); // expected-error{{no member named 'PopCleanupScope' in 'PR7508::A'}}
+ }
+}
diff --git a/test/SemaCXX/new-array-size-conv.cpp b/test/SemaCXX/new-array-size-conv.cpp
new file mode 100644
index 0000000..80219a9
--- /dev/null
+++ b/test/SemaCXX/new-array-size-conv.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
+
+struct ValueInt
+{
+ ValueInt(int v = 0) : ValueLength(v) {}
+ operator int () const { return ValueLength; } // expected-note 3{{conversion to integral type 'int' declared here}}
+private:
+ int ValueLength;
+};
+
+enum E { e };
+struct ValueEnum {
+ operator E() const; // expected-note{{conversion to enumeration type 'E' declared here}}
+};
+
+struct ValueBoth : ValueInt, ValueEnum { };
+
+struct IndirectValueInt : ValueInt { };
+struct TwoValueInts : ValueInt, IndirectValueInt { };
+
+void test() {
+ (void)new int[ValueInt(10)]; // expected-warning{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++0x extension}}
+ (void)new int[ValueEnum()]; // expected-warning{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++0x extension}}
+ (void)new int[ValueBoth()]; // expected-error{{ambiguous conversion of array size expression of type 'ValueBoth' to an integral or enumeration type}}
+
+ (void)new int[TwoValueInts()]; // expected-error{{ambiguous conversion of array size expression of type 'TwoValueInts' to an integral or enumeration type}}
+}
diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp
index 3f1da02..25bf823 100644
--- a/test/SemaCXX/new-delete.cpp
+++ b/test/SemaCXX/new-delete.cpp
@@ -68,7 +68,7 @@ void bad_news(int *ip)
(void)new int[1.1]; // expected-error {{array size expression must have integral or enumerated type, not 'double'}}
(void)new int[1][i]; // expected-error {{only the first dimension}}
(void)new (int[1][i]); // expected-error {{only the first dimension}}
- (void)new (int[i]); // expected-error {{when type is in parentheses}}
+ (void)new (int[i]); // expected-warning {{when type is in parentheses}}
(void)new int(*(S*)0); // expected-error {{no viable conversion from 'S' to 'int'}}
(void)new int(1, 2); // expected-error {{excess elements in scalar initializer}}
(void)new S(1); // expected-error {{no matching constructor}}
@@ -263,3 +263,50 @@ template void h<unsigned>(unsigned);
template void h<unsigned[10]>(unsigned); // expected-note {{in instantiation of function template specialization 'Test1::h<unsigned int [10]>' requested here}}
}
+
+// Don't diagnose access for overload candidates that aren't selected.
+namespace PR7436 {
+struct S1 {
+ void* operator new(size_t);
+ void operator delete(void* p);
+
+private:
+ void* operator new(size_t, void*); // expected-note {{declared private here}}
+ void operator delete(void*, void*);
+};
+class S2 {
+ void* operator new(size_t); // expected-note {{declared private here}}
+ void operator delete(void* p); // expected-note {{declared private here}}
+};
+
+void test(S1* s1, S2* s2) {
+ delete s1;
+ delete s2; // expected-error {{is a private member}}
+ (void)new S1();
+ (void)new (0L) S1(); // expected-error {{is a private member}}
+ (void)new S2(); // expected-error {{is a private member}}
+}
+}
+
+namespace rdar8018245 {
+ struct X0 {
+ static const int value = 17;
+ };
+
+ const int X0::value;
+
+ struct X1 {
+ static int value;
+ };
+
+ int X1::value;
+
+ template<typename T>
+ int *f() {
+ return new (int[T::value]); // expected-warning{{when type is in parentheses, array cannot have dynamic size}}
+ }
+
+ template int *f<X0>();
+ template int *f<X1>(); // expected-note{{in instantiation of}}
+
+}
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index 29133c7..6bf6965 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -54,6 +54,7 @@ double* k(bool);
void test_k() {
int* ip1 = k("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
+ int* ip2 = k(("foo")); // expected-warning{{conversion from string literal to 'char *' is deprecated}}
double* dp1 = k(L"foo");
}
@@ -218,6 +219,12 @@ void test_derived(B* b, B const* bc, C* c, const C* cc, void* v, D* d) {
char* d8 = derived3(d);
}
+void derived4(C*); // expected-note{{candidate function not viable: cannot convert from base class pointer 'A *' to derived class pointer 'C *' for 1st argument}}
+
+void test_base(A* a) {
+ derived4(a); // expected-error{{no matching function for call to 'derived4}}
+}
+
// Test overloading of references.
// (FIXME: tests binding to determine candidate sets, not overload
// resolution per se).
@@ -229,6 +236,12 @@ void intref_test() {
float* ir2 = intref(5.5);
}
+void derived5(C&); // expected-note{{candidate function not viable: cannot bind base class object of type 'A' to derived class reference 'C &' for 1st argument}}
+
+void test_base(A& a) {
+ derived5(a); // expected-error{{no matching function for call to 'derived5}}
+}
+
// Test reference binding vs. standard conversions.
int& bind_vs_conv(const double&);
float& bind_vs_conv(int);
@@ -460,3 +473,20 @@ namespace PR7224 {
float &fr = foo(d2);
}
}
+
+namespace NontrivialSubsequence {
+ struct X0;
+
+ class A {
+ operator X0 *();
+ public:
+ operator const X0 *();
+ };
+
+ A a;
+ void foo( void const * );
+
+ void g() {
+ foo(a);
+ }
+}
diff --git a/test/SemaCXX/overloaded-builtin-operators.cpp b/test/SemaCXX/overloaded-builtin-operators.cpp
index 61c2e21..8a49671 100644
--- a/test/SemaCXX/overloaded-builtin-operators.cpp
+++ b/test/SemaCXX/overloaded-builtin-operators.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify %s
struct yes;
struct no;
@@ -173,7 +173,8 @@ struct A {
void test_dr425(A a) {
// FIXME: lots of candidates here!
(void)(1.0f * a); // expected-error{{ambiguous}} \
- // expected-note 81{{candidate}}
+ // expected-note 4{{candidate}} \
+ // expected-note {{remaining 77 candidates omitted; pass -fshow-overloads=all to show them}}
}
// pr5432
@@ -188,3 +189,14 @@ int test_pr5432() {
void f() {
(void)__extension__(A());
}
+
+namespace PR7319 {
+ typedef enum { Enum1, Enum2, Enum3 } MyEnum;
+
+ template<typename X> bool operator>(const X &inX1, const X &inX2);
+
+ void f() {
+ MyEnum e1, e2;
+ if (e1 > e2) {}
+ }
+}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 3d737f4..24f7f66 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -49,6 +49,13 @@ struct B {
}
};
+// we shouldn't see warnings about self-comparison,
+// this is a member function, we dunno what it'll do
+bool i(B b)
+{
+ return b == b;
+}
+
enum Enum1 { };
enum Enum2 { };
@@ -150,7 +157,7 @@ bool& operator,(X, Y);
void test_comma(X x, Y y) {
bool& b1 = (x, y);
- X& xr = (x, x);
+ X& xr = (x, x); // expected-warning {{expression result unused}}
}
struct Callable {
diff --git a/test/SemaCXX/pseudo-destructors.cpp b/test/SemaCXX/pseudo-destructors.cpp
index 472e5b4..30d9faa 100644
--- a/test/SemaCXX/pseudo-destructors.cpp
+++ b/test/SemaCXX/pseudo-destructors.cpp
@@ -14,6 +14,11 @@ namespace N {
typedef int OtherInteger;
}
+template <typename T>
+void cv_test(const volatile T* cvt) {
+ cvt->T::~T(); // no-warning
+}
+
void f(A* a, Foo *f, int *i, double *d) {
a->~A();
a->A::~A();
@@ -41,8 +46,14 @@ void f(A* a, Foo *f, int *i, double *d) {
i->N::OtherInteger::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
i->N::~Integer(); // expected-error{{'Integer' does not refer to a type name in pseudo-destructor expression; expected the name of type 'int'}}
i->Integer::~Double(); // expected-error{{the type of object expression ('int') does not match the type being destroyed ('Double' (aka 'double')) in pseudo-destructor expression}}
+
+ cv_test(a);
+ cv_test(f);
+ cv_test(i);
+ cv_test(d);
}
+
typedef int Integer;
void destroy_without_call(int *ip) {
@@ -57,3 +68,4 @@ namespace N1 {
void test_X0(N1::X0 &x0) {
x0.~X0();
}
+
diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp
index 45d41e8..f054e52 100644
--- a/test/SemaCXX/reinterpret-cast.cpp
+++ b/test/SemaCXX/reinterpret-cast.cpp
@@ -91,8 +91,20 @@ void memptrs()
(void)reinterpret_cast<int structure::*>(0); // expected-error {{reinterpret_cast from 'int' to 'int structure::*' is not allowed}}
}
+namespace PR5545 {
// PR5545
class A;
class B;
void (A::*a)();
void (B::*b)() = reinterpret_cast<void (B::*)()>(a);
+}
+
+// <rdar://problem/8018292>
+void const_arrays() {
+ typedef char STRING[10];
+ const STRING *s;
+ const char *c;
+
+ (void)reinterpret_cast<char *>(s); // expected-error {{reinterpret_cast from 'STRING const *' (aka 'char const (*)[10]') to 'char *' casts away constness}}
+ (void)reinterpret_cast<const STRING *>(c);
+}
diff --git a/test/SemaCXX/rval-references.cpp b/test/SemaCXX/rval-references.cpp
index d5b465f..30622cc 100644
--- a/test/SemaCXX/rval-references.cpp
+++ b/test/SemaCXX/rval-references.cpp
@@ -21,6 +21,10 @@ struct conv_to_not_int_rvalue {
operator not_int &&();
};
+typedef void (fun_type)();
+void fun();
+fun_type &&make_fun();
+
void f() {
int &&virr1; // expected-error {{declaration of reference variable 'virr1' requires an initializer}}
int &&virr2 = 0;
@@ -47,6 +51,9 @@ void f() {
not_int &ni5 = cnir; // expected-error{{non-const lvalue reference to type 'not_int' cannot bind to a value of unrelated type 'conv_to_not_int_rvalue'}}
not_int &&ni6 = conv_to_not_int_rvalue();
+ fun_type &&fun_ref = fun; // works because functions are special
+ fun_type &&fun_ref2 = make_fun(); // same
+ fun_type &fun_lref = make_fun(); // also special
try {
} catch(int&&) { // expected-error {{cannot catch exceptions by rvalue reference}}
diff --git a/test/SemaCXX/typedef-redecl.cpp b/test/SemaCXX/typedef-redecl.cpp
index 49e1f3a..7db1970 100644
--- a/test/SemaCXX/typedef-redecl.cpp
+++ b/test/SemaCXX/typedef-redecl.cpp
@@ -48,3 +48,9 @@ namespace PR6923 {
struct A;
}
+
+namespace PR7462 {
+ struct A {};
+ typedef int operator! (A); // expected-error{{typedef name must be an identifier}}
+ int i = !A(); // expected-error{{invalid argument type}}
+}
diff --git a/test/SemaCXX/using-directive.cpp b/test/SemaCXX/using-directive.cpp
index 0d5c840..162f7fa0 100644
--- a/test/SemaCXX/using-directive.cpp
+++ b/test/SemaCXX/using-directive.cpp
@@ -121,3 +121,8 @@ extern "C++" {
}
void f4() { f2(1); }
+
+// PR7517
+using namespace std; // expected-warning{{using directive refers to implicitly-defined namespace 'std'}}
+using namespace ::std; // expected-warning{{using directive refers to implicitly-defined namespace 'std'}}
+
diff --git a/test/SemaCXX/vector.cpp b/test/SemaCXX/vector.cpp
index b548865..66b2d68 100644
--- a/test/SemaCXX/vector.cpp
+++ b/test/SemaCXX/vector.cpp
@@ -186,3 +186,33 @@ void test_implicit_conversions(bool Cond, char16 c16, longlong16 ll16,
(void)(Cond? to_c16 : to_ll16); // expected-error{{can't convert between vector values of different size}}
(void)(Cond? to_c16e : to_ll16e); // expected-error{{can't convert between vector values of different size}}
}
+
+typedef float fltx2 __attribute__((__vector_size__(8)));
+typedef float fltx4 __attribute__((__vector_size__(16)));
+typedef double dblx2 __attribute__((__vector_size__(16)));
+typedef double dblx4 __attribute__((__vector_size__(32)));
+
+void accept_fltx2(fltx2); // expected-note{{candidate function not viable: no known conversion from 'double' to 'fltx2' for 1st argument}}
+void accept_fltx4(fltx4);
+void accept_dblx2(dblx2);
+void accept_dblx4(dblx4);
+void accept_bool(bool); // expected-note{{candidate function not viable: no known conversion from 'fltx2' to 'bool' for 1st argument}}
+
+void test(fltx2 fltx2_val, fltx4 fltx4_val, dblx2 dblx2_val, dblx4 dblx4_val) {
+ // Exact matches
+ accept_fltx2(fltx2_val);
+ accept_fltx4(fltx4_val);
+ accept_dblx2(dblx2_val);
+ accept_dblx4(dblx4_val);
+
+ // Same-size conversions
+ // FIXME: G++ rejects these conversions, we accept them. Revisit this!
+ accept_fltx4(dblx2_val);
+ accept_dblx2(fltx4_val);
+
+ // Conversion to bool.
+ accept_bool(fltx2_val); // expected-error{{no matching function for call to 'accept_bool'}}
+
+ // Scalar-to-vector conversions.
+ accept_fltx2(1.0); // expected-error{{no matching function for call to 'accept_fltx2'}}
+}
diff --git a/test/SemaCXX/warn-self-comparisons.cpp b/test/SemaCXX/warn-self-comparisons.cpp
new file mode 100644
index 0000000..620be19
--- /dev/null
+++ b/test/SemaCXX/warn-self-comparisons.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f(int (&array1)[2], int (&array2)[2]) {
+ if (array1 == array2) { } // no warning
+}
diff --git a/test/SemaCXX/warn-unreachable.cpp b/test/SemaCXX/warn-unreachable.cpp
index 01b36de..f5601cd 100644
--- a/test/SemaCXX/warn-unreachable.cpp
+++ b/test/SemaCXX/warn-unreachable.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang %s -fsyntax-only -Xclang -verify -fblocks -Wunreachable-code -Wno-unused-value
+// RUN: %clang_cc1 %s -fsyntax-only -verify -fblocks -Wunreachable-code -Wno-unused-value
int &halt() __attribute__((noreturn));
int &live();
diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp
index 5ef7e70..6992cdc 100644
--- a/test/SemaCXX/warn-unused-variables.cpp
+++ b/test/SemaCXX/warn-unused-variables.cpp
@@ -26,7 +26,7 @@ namespace PR5531 {
};
void test() {
- A(); // expected-warning{{expression result unused}}
+ A();
B(17);
C();
}
diff --git a/test/SemaCXX/warn_false_to_pointer.cpp b/test/SemaCXX/warn_false_to_pointer.cpp
new file mode 100644
index 0000000..3a873d8
--- /dev/null
+++ b/test/SemaCXX/warn_false_to_pointer.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int* j = false; // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}}
+
+void foo(int* i, int *j=(false)) // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}}
+{
+ foo(false); // expected-warning{{ initialization of pointer of type 'int *' from literal 'false'}}
+}
+
diff --git a/test/SemaCXX/wchar_t.cpp b/test/SemaCXX/wchar_t.cpp
index 789dbf6..f9d7b61 100644
--- a/test/SemaCXX/wchar_t.cpp
+++ b/test/SemaCXX/wchar_t.cpp
@@ -25,3 +25,8 @@ int t(void) {
basic_string<wchar_t>() + L'-';
return (0);
}
+
+
+// rdar://8040728
+wchar_t in[] = L"\x434" "\x434"; // No warning
+
OpenPOWER on IntegriCloud