aboutsummaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/Inputs/lit.local.cfg1
-rw-r--r--test/SemaCXX/Inputs/malloc.h3
-rw-r--r--test/SemaCXX/access-base-class.cpp23
-rw-r--r--test/SemaCXX/access-control-check.cpp2
-rw-r--r--test/SemaCXX/aggregate-initialization.cpp39
-rw-r--r--test/SemaCXX/builtin-exception-spec.cpp6
-rw-r--r--test/SemaCXX/builtins.cpp2
-rw-r--r--test/SemaCXX/cast-conversion.cpp2
-rw-r--r--test/SemaCXX/comma.cpp8
-rw-r--r--test/SemaCXX/conditional-expr.cpp10
-rw-r--r--test/SemaCXX/constructor-initializer.cpp8
-rw-r--r--test/SemaCXX/copy-assignment.cpp8
-rw-r--r--test/SemaCXX/dcl_ambig_res.cpp4
-rw-r--r--test/SemaCXX/dcl_init_aggr.cpp2
-rw-r--r--test/SemaCXX/decl-init-ref.cpp3
-rw-r--r--test/SemaCXX/enum.cpp4
-rw-r--r--test/SemaCXX/explicit.cpp39
-rw-r--r--test/SemaCXX/i-c-e-cxx.cpp16
-rw-r--r--test/SemaCXX/illegal-member-initialization.cpp7
-rw-r--r--test/SemaCXX/namespace-alias.cpp21
-rw-r--r--test/SemaCXX/nested-name-spec.cpp11
-rw-r--r--test/SemaCXX/new-delete-predefined-decl.cpp19
-rw-r--r--test/SemaCXX/new-delete.cpp15
-rw-r--r--test/SemaCXX/overload-call-copycon.cpp3
-rw-r--r--test/SemaCXX/overload-call.cpp12
-rw-r--r--test/SemaCXX/overload-member-call.cpp2
-rw-r--r--test/SemaCXX/overloaded-operator-decl.cpp6
-rw-r--r--test/SemaCXX/overloaded-operator.cpp2
-rw-r--r--test/SemaCXX/references.cpp13
-rw-r--r--test/SemaCXX/reinterpret-cast.cpp2
-rw-r--r--test/SemaCXX/static-cast.cpp11
-rw-r--r--test/SemaCXX/templated-friend-decl.cpp15
-rw-r--r--test/SemaCXX/using-decl-1.cpp35
-rw-r--r--test/SemaCXX/virtual-override.cpp27
-rw-r--r--test/SemaCXX/warn-missing-noreturn.cpp24
-rw-r--r--test/SemaCXX/warn-unused-variables.cpp18
-rw-r--r--test/SemaCXX/warn-weak-vtables.cpp21
37 files changed, 398 insertions, 46 deletions
diff --git a/test/SemaCXX/Inputs/lit.local.cfg b/test/SemaCXX/Inputs/lit.local.cfg
new file mode 100644
index 000000000000..e6f55eef7af5
--- /dev/null
+++ b/test/SemaCXX/Inputs/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = []
diff --git a/test/SemaCXX/Inputs/malloc.h b/test/SemaCXX/Inputs/malloc.h
new file mode 100644
index 000000000000..c54d6215017b
--- /dev/null
+++ b/test/SemaCXX/Inputs/malloc.h
@@ -0,0 +1,3 @@
+extern "C" {
+extern void *malloc (__SIZE_TYPE__ __size) throw () __attribute__ ((__malloc__)) ;
+}
diff --git a/test/SemaCXX/access-base-class.cpp b/test/SemaCXX/access-base-class.cpp
index f4c58d940b63..d0b0fb8ee223 100644
--- a/test/SemaCXX/access-base-class.cpp
+++ b/test/SemaCXX/access-base-class.cpp
@@ -2,10 +2,10 @@
namespace T1 {
class A { };
-class B : private A { }; // expected-note {{'private' inheritance specifier here}}
+class B : private A { }; // expected-note {{declared private here}}
void f(B* b) {
- A *a = b; // expected-error{{conversion from 'class T1::B' to inaccessible base class 'class T1::A'}}
+ A *a = b; // expected-error{{cannot cast 'class T1::B' to its private base class 'class T1::A'}}
}
}
@@ -13,10 +13,10 @@ void f(B* b) {
namespace T2 {
class A { };
-class B : A { }; // expected-note {{inheritance is implicitly 'private'}}
+class B : A { }; // expected-note {{implicitly declared private here}}
void f(B* b) {
- A *a = b; // expected-error {{conversion from 'class T2::B' to inaccessible base class 'class T2::A'}}
+ A *a = b; // expected-error {{cannot cast 'class T2::B' to its private base class 'class T2::A'}}
}
}
@@ -63,13 +63,13 @@ namespace T6 {
class A {};
- class B : private A { // expected-note {{'private' inheritance specifier here}}
+ class B : private A { // expected-note {{declared private here}}
void f(C* c);
};
class C : public B {
void f(C *c) {
- A* a = c; // expected-error {{conversion from 'class T6::C' to inaccessible base class 'class T6::A'}}
+ A* a = c; // expected-error {{cannot cast 'class T6::C' to its private base class 'class T6::A'}}
}
};
@@ -77,3 +77,14 @@ namespace T6 {
A *a = c;
}
}
+
+namespace T7 {
+ class A {};
+ class B : public A {};
+ class C : private B {
+ void f(C *c) {
+ A* a = c; // okay
+ }
+ };
+}
+
diff --git a/test/SemaCXX/access-control-check.cpp b/test/SemaCXX/access-control-check.cpp
index cf2d191a294f..783d4def5327 100644
--- a/test/SemaCXX/access-control-check.cpp
+++ b/test/SemaCXX/access-control-check.cpp
@@ -11,5 +11,5 @@ class P {
class N : M,P {
N() {}
- int PR() { return iP + PPR(); } // expected-error 2 {{access to private member of 'class P'}}
+ int PR() { return iP + PPR(); } // expected-error 2 {{private member of 'class P'}}
};
diff --git a/test/SemaCXX/aggregate-initialization.cpp b/test/SemaCXX/aggregate-initialization.cpp
index ac482151fac1..83f4179d9136 100644
--- a/test/SemaCXX/aggregate-initialization.cpp
+++ b/test/SemaCXX/aggregate-initialization.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
// Verify that we can't initialize non-aggregates with an initializer
// list.
@@ -30,3 +30,40 @@ NonAggr4 na4 = { 17 }; // expected-error{{non-aggregate type 'struct NonAggr4' c
// PR5817
typedef int type[][2];
const type foo = {0};
+
+// Vector initialization.
+typedef short __v4hi __attribute__ ((__vector_size__ (8)));
+__v4hi v1 = { (void *)1, 2, 3 }; // expected-error {{cannot initialize a vector element of type 'short' with an rvalue of type 'void *'}}
+
+// Array initialization.
+int a[] = { (void *)1 }; // expected-error {{cannot initialize an array element of type 'int' with an rvalue of type 'void *'}}
+
+// Struct initialization.
+struct S { int a; } s = { (void *)1 }; // expected-error {{cannot initialize a member subobject of type 'int' with an rvalue of type 'void *'}}
+
+// Check that we're copy-initializing the structs.
+struct A {
+ A();
+ A(int);
+ ~A();
+
+ A(const A&) = delete; // expected-note 2 {{function has been explicitly marked deleted here}}
+};
+
+struct B {
+ A a;
+};
+
+struct C {
+ const A& a;
+};
+
+void f() {
+ A as1[1] = { };
+ A as2[1] = { 1 }; // expected-error {{copying array element of type 'struct A' invokes deleted copy constructor}}
+
+ B b1 = { };
+ B b2 = { 1 }; // expected-error {{copying member subobject of type 'struct A' invokes deleted copy constructor}}
+
+ C c1 = { 1 };
+}
diff --git a/test/SemaCXX/builtin-exception-spec.cpp b/test/SemaCXX/builtin-exception-spec.cpp
new file mode 100644
index 000000000000..324d20ea6a15
--- /dev/null
+++ b/test/SemaCXX/builtin-exception-spec.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -isystem %S/Inputs -fsyntax-only -verify %s
+#include <malloc.h>
+
+extern "C" {
+void *malloc(__SIZE_TYPE__);
+}
diff --git a/test/SemaCXX/builtins.cpp b/test/SemaCXX/builtins.cpp
index a75b4f2e403a..568ba5dde129 100644
--- a/test/SemaCXX/builtins.cpp
+++ b/test/SemaCXX/builtins.cpp
@@ -5,3 +5,5 @@ typedef const struct __CFString * CFStringRef;
void f() {
(void)CFStringRef(CFSTR("Hello"));
}
+
+void a() { __builtin_va_list x, y; ::__builtin_va_copy(x, y); }
diff --git a/test/SemaCXX/cast-conversion.cpp b/test/SemaCXX/cast-conversion.cpp
index 77f4a528906d..074e1330403d 100644
--- a/test/SemaCXX/cast-conversion.cpp
+++ b/test/SemaCXX/cast-conversion.cpp
@@ -30,7 +30,7 @@ X0<T> make_X0(const T &Val) {
}
void test_X0() {
- const char array[2];
+ const char array[2] = { 'a', 'b' };
make_X0(array);
}
diff --git a/test/SemaCXX/comma.cpp b/test/SemaCXX/comma.cpp
new file mode 100644
index 000000000000..79ff7d1cde25
--- /dev/null
+++ b/test/SemaCXX/comma.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR6076
+void f();
+void (&g)() = (void(), f);
+
+int a[1];
+int (&b)[1] = (void(), a);
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index b71133bfeec8..b961ff2de910 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -25,7 +25,7 @@ struct Derived : Base {
void fn2();
};
struct Convertible { operator Base&(); };
-struct Priv : private Base {}; // expected-note 4 {{'private' inheritance specifier here}}
+struct Priv : private Base {}; // expected-note 4 {{declared private here}}
struct Mid : Base {};
struct Fin : Mid, Derived {};
typedef void (Derived::*DFnPtr)();
@@ -111,12 +111,12 @@ void test()
Priv priv;
Fin fin;
- (void)(i1 ? Base() : Priv()); // expected-error{{conversion from 'struct Priv' to inaccessible base class 'struct Base'}}
- (void)(i1 ? Priv() : Base()); // expected-error{{error: conversion from 'struct Priv' to inaccessible base class 'struct Base'}}
+ (void)(i1 ? Base() : Priv()); // expected-error{{private base class}}
+ (void)(i1 ? Priv() : Base()); // expected-error{{private base class}}
(void)(i1 ? Base() : Fin()); // expected-error{{ambiguous conversion from derived class 'struct Fin' to base class 'struct Base'}}
(void)(i1 ? Fin() : Base()); // expected-error{{ambiguous conversion from derived class 'struct Fin' to base class 'struct Base'}}
- (void)(i1 ? base : priv); // expected-error {{conversion from 'struct Priv' to inaccessible base class 'struct Base'}}
- (void)(i1 ? priv : base); // expected-error {{conversion from 'struct Priv' to inaccessible base class 'struct Base'}}
+ (void)(i1 ? base : priv); // expected-error {{private base class}}
+ (void)(i1 ? priv : base); // expected-error {{private base class}}
(void)(i1 ? base : fin); // expected-error {{ambiguous conversion from derived class 'struct Fin' to base class 'struct Base'}}
(void)(i1 ? fin : base); // expected-error {{ambiguous conversion from derived class 'struct Fin' to base class 'struct Base'}}
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index 53f057ed0f35..2efb7b9c2145 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -104,8 +104,8 @@ struct M { // expected-note 2 {{candidate constructor (the implicit
};
struct N : M {
- N() : M(1), // expected-error {{no matching constructor for initialization of 'M'}}
- m1(100) { } // expected-error {{no matching constructor for initialization of 'm1'}}
+ N() : M(1), // expected-error {{no matching constructor for initialization of 'struct M'}}
+ m1(100) { } // expected-error {{no matching constructor for initialization of 'struct M'}}
M m1;
};
@@ -116,8 +116,8 @@ struct P : M {
};
struct Q {
- Q() : f1(1,2), // expected-error {{Too many arguments for member initializer 'f1'}}
- pf(0.0) { } // expected-error {{incompatible type passing 'double', expected 'float *'}}
+ Q() : f1(1,2), // expected-error {{excess elements in scalar initializer}}
+ pf(0.0) { } // expected-error {{cannot initialize a member subobject of type 'float *' with an rvalue of type 'double'}}
float f1;
float *pf;
diff --git a/test/SemaCXX/copy-assignment.cpp b/test/SemaCXX/copy-assignment.cpp
index 315e29a5b5ec..d7eb5cf1e60d 100644
--- a/test/SemaCXX/copy-assignment.cpp
+++ b/test/SemaCXX/copy-assignment.cpp
@@ -47,22 +47,22 @@ struct ConvertibleToInt {
void test() {
A a, na;
- const A constA;
+ const A constA = A();
ConvertibleToA convertibleToA;
ConvertibleToConstA convertibleToConstA;
B b, nb;
- const B constB;
+ const B constB = B();
ConvertibleToB convertibleToB;
ConvertibleToBref convertibleToBref;
ConvertibleToConstB convertibleToConstB;
ConvertibleToConstBref convertibleToConstBref;
C c, nc;
- const C constC;
+ const C constC = C();
D d, nd;
- const D constD;
+ const D constD = D();
ConvertibleToInt convertibleToInt;
diff --git a/test/SemaCXX/dcl_ambig_res.cpp b/test/SemaCXX/dcl_ambig_res.cpp
index 859d2045da09..f0ba2978e8d7 100644
--- a/test/SemaCXX/dcl_ambig_res.cpp
+++ b/test/SemaCXX/dcl_ambig_res.cpp
@@ -12,8 +12,8 @@ void foo(double a)
{
S w(int(a)); // expected-warning{{disambiguated}}
w(17);
- S x(int()); // expected-warning{{disambiguated}}
- x(&returns_an_int);
+ S x1(int()); // expected-warning{{disambiguated}}
+ x1(&returns_an_int);
S y((int)a);
y.bar();
S z = int(a);
diff --git a/test/SemaCXX/dcl_init_aggr.cpp b/test/SemaCXX/dcl_init_aggr.cpp
index 07ddb0add2ca..861eb3dcb163 100644
--- a/test/SemaCXX/dcl_init_aggr.cpp
+++ b/test/SemaCXX/dcl_init_aggr.cpp
@@ -120,4 +120,4 @@ u u1 = { 1 };
u u2 = u1;
u u3 = 1; // expected-error{{no viable conversion}}
u u4 = { 0, "asdf" }; // expected-error{{excess elements in union initializer}}
-u u5 = { "asdf" }; // expected-error{{incompatible type initializing 'char const [5]', expected 'int'}}
+u u5 = { "asdf" }; // expected-error{{cannot initialize a member subobject of type 'int' with an lvalue of type 'char const [5]'}}
diff --git a/test/SemaCXX/decl-init-ref.cpp b/test/SemaCXX/decl-init-ref.cpp
index 656f3436a0c3..2f7d8a4c77ef 100644
--- a/test/SemaCXX/decl-init-ref.cpp
+++ b/test/SemaCXX/decl-init-ref.cpp
@@ -24,3 +24,6 @@ int main() {
const A& rca = f(); // expected-error {{reference initialization of type 'struct A const &' with initializer of type 'class B' is ambiguous}}
A& ra = f(); // expected-error {{non-const lvalue reference to type 'struct A' cannot bind to a temporary of type 'class B'}}
}
+
+struct PR6139 { A (&x)[1]; };
+PR6139 x = {{A()}}; // expected-error{{non-const lvalue reference to type 'struct A [1]' cannot bind to a temporary of type 'struct A'}}
diff --git a/test/SemaCXX/enum.cpp b/test/SemaCXX/enum.cpp
index 47ae06ab0e69..dc4a506dda21 100644
--- a/test/SemaCXX/enum.cpp
+++ b/test/SemaCXX/enum.cpp
@@ -67,3 +67,7 @@ namespace PR6061 {
enum { id };
};
}
+
+namespace Conditional {
+ enum a { A }; a x(const enum a x) { return 1?x:A; }
+}
diff --git a/test/SemaCXX/explicit.cpp b/test/SemaCXX/explicit.cpp
new file mode 100644
index 000000000000..717ed1e3caf2
--- /dev/null
+++ b/test/SemaCXX/explicit.cpp
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x %s
+namespace Constructor {
+struct A {
+ A(int);
+};
+
+struct B {
+ explicit B(int);
+};
+
+B::B(int) { }
+
+struct C {
+ void f(const A&);
+ void f(const B&);
+};
+
+void f(C c) {
+ c.f(10);
+}
+}
+
+namespace Conversion {
+ struct A {
+ operator int();
+ explicit operator bool();
+ };
+
+ A::operator bool() { return false; }
+
+ struct B {
+ void f(int);
+ void f(bool);
+ };
+
+ void f(A a, B b) {
+ b.f(a);
+ }
+}
diff --git a/test/SemaCXX/i-c-e-cxx.cpp b/test/SemaCXX/i-c-e-cxx.cpp
index 8c70bc258701..4f2f19746783 100644
--- a/test/SemaCXX/i-c-e-cxx.cpp
+++ b/test/SemaCXX/i-c-e-cxx.cpp
@@ -21,3 +21,19 @@ int a() {
case t:; // expected-error {{not an integer constant expression}}
}
}
+
+// PR6206: out-of-line definitions are legit
+namespace pr6206 {
+ class Foo {
+ public:
+ static const int kBar;
+ };
+
+ const int Foo::kBar = 20;
+
+ char Test() {
+ char str[Foo::kBar];
+ str[0] = '0';
+ return str[0];
+ }
+}
diff --git a/test/SemaCXX/illegal-member-initialization.cpp b/test/SemaCXX/illegal-member-initialization.cpp
index 1890dbc9b594..be5f91d51ac8 100644
--- a/test/SemaCXX/illegal-member-initialization.cpp
+++ b/test/SemaCXX/illegal-member-initialization.cpp
@@ -1,9 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A {
- A() : value(), cvalue() { } // expected-error {{cannot initialize the member to null in default constructor because reference member 'value' cannot be null-initialized}} \
- // expected-error {{constructor for 'struct A' must explicitly initialize the reference member 'value'}}
- int &value; // expected-note{{declared at}} {{expected-note{{declared at}}
+ A() : value(), cvalue() { } // expected-error {{reference to type 'int' requires an initializer}}
+ int &value;
const int cvalue;
};
@@ -18,7 +17,7 @@ struct X {
int &value; // expected-note{{declared at}}
const int cvalue; // expected-note{{declared at}}
B& b; // expected-note{{declared at}}
- const B cb; // expected-note{{declared at}}
+ const B cb; // expected-note{{declared here}}
};
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index f9836064d131..06114c34cc47 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -62,3 +62,24 @@ namespace J {
func();
}
}
+
+namespace K {
+ namespace KA { void func(); }
+
+ void f() {
+ namespace KB = KA;
+ KB::func();
+ }
+
+ template <class T> void g() {
+ namespace KC = KA;
+ KC::func();
+ }
+ template void g<int>();
+ template void g<long>();
+
+ void h() {
+ KB::func(); // expected-error {{undeclared identifier 'KB'}}
+ KC::func(); // expected-error {{undeclared identifier 'KC'}}
+ }
+}
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp
index 8618f0339bca..8a217b312088 100644
--- a/test/SemaCXX/nested-name-spec.cpp
+++ b/test/SemaCXX/nested-name-spec.cpp
@@ -212,7 +212,7 @@ namespace test1 {
// non-lexical scope.
namespace test2 {
namespace ns {
- int *count_ptr;
+ extern int *count_ptr;
}
namespace {
int count = 0;
@@ -220,3 +220,12 @@ namespace test2 {
int *ns::count_ptr = &count;
}
+
+// PR6259, invalid case
+namespace test3 {
+ // FIXME: this should really only trigger once
+ class A; // expected-note 2 {{forward declaration}}
+ void foo(const char *path) {
+ A::execute(path); // expected-error 2 {{incomplete type 'class test3::A' named in nested name specifier}}
+ }
+}
diff --git a/test/SemaCXX/new-delete-predefined-decl.cpp b/test/SemaCXX/new-delete-predefined-decl.cpp
new file mode 100644
index 000000000000..20b15b729cd0
--- /dev/null
+++ b/test/SemaCXX/new-delete-predefined-decl.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -DTEMPLATE_OVERLOAD -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include <stddef.h>
+
+// Note that each test must be run separately so it can be the first operator
+// new declaration in the file.
+
+#if defined(TEMPLATE_OVERLOAD)
+// Don't crash on global template operator new overloads.
+template<typename T> void* operator new(size_t, T);
+void test_template_overload() {
+ (void)new(0) double;
+}
+#endif
+
+void test_predefined() {
+ (void)new double;
+}
diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp
index b058fc13d96f..acd4a23cb35a 100644
--- a/test/SemaCXX/new-delete.cpp
+++ b/test/SemaCXX/new-delete.cpp
@@ -216,3 +216,18 @@ static void* f(void* g)
{
return new (g) X13();
}
+
+class X14 {
+ static void operator delete(void*, const size_t);
+};
+
+void f(X14 *x14a, X14 *x14b) {
+ delete x14a;
+}
+
+namespace PR5918 { // Look for template operator new overloads.
+ struct S { template<typename T> static void* operator new(size_t, T); };
+ void test() {
+ (void)new(0) S;
+ }
+}
diff --git a/test/SemaCXX/overload-call-copycon.cpp b/test/SemaCXX/overload-call-copycon.cpp
index 472fae26b81f..f57484e5069a 100644
--- a/test/SemaCXX/overload-call-copycon.cpp
+++ b/test/SemaCXX/overload-call-copycon.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only %s -Wnon-pod-varargs
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs
class X { };
int& copycon(X x);
@@ -37,7 +37,6 @@ void test_copycon3(B b, const B bc) {
float& f1 = copycon3(bc); // expected-warning {{cannot pass object of non-POD type}}
}
-
class C : public B { };
float& copycon4(A a);
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index 12dc5daccb6d..e2a4fd8a0d59 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -347,3 +347,15 @@ namespace test3 {
foo(*P); // expected-error {{no matching function for call to 'foo'}}
}
}
+
+namespace DerivedToBaseVsVoid {
+ struct A { };
+ struct B : A { };
+
+ float &f(void *);
+ int &f(const A*);
+
+ void g(B *b) {
+ int &ir = f(b);
+ }
+}
diff --git a/test/SemaCXX/overload-member-call.cpp b/test/SemaCXX/overload-member-call.cpp
index 22416f3ea48e..77d9965ab796 100644
--- a/test/SemaCXX/overload-member-call.cpp
+++ b/test/SemaCXX/overload-member-call.cpp
@@ -89,7 +89,7 @@ namespace test1 {
A a;
a.foo(4, "hello"); //expected-error {{no matching member function for call to 'foo'}}
- const A b;
+ const A b = A();
b.bar(0); //expected-error {{no matching member function for call to 'bar'}}
a.baz(b); //expected-error {{no matching member function for call to 'baz'}}
diff --git a/test/SemaCXX/overloaded-operator-decl.cpp b/test/SemaCXX/overloaded-operator-decl.cpp
index c43d7c217cca..5f8655cee70c 100644
--- a/test/SemaCXX/overloaded-operator-decl.cpp
+++ b/test/SemaCXX/overloaded-operator-decl.cpp
@@ -37,3 +37,9 @@ Y operator++(Y&, INT);
X operator++(X&, FLOAT); // expected-error{{parameter of overloaded post-increment operator must have type 'int' (not 'FLOAT' (aka 'float'))}}
int operator+; // expected-error{{'operator+' cannot be the name of a variable or data member}}
+
+namespace PR6238 {
+ static struct {
+ void operator()();
+ } plus;
+}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 861d679c7261..e07afe202031 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -344,7 +344,7 @@ namespace pr5900 {
int operator[](unsigned); // expected-note {{candidate}}
};
int test1() {
- const NonConstArray x;
+ const NonConstArray x = NonConstArray();
return x[0]; // expected-error {{no viable overloaded operator[] for type}}
}
diff --git a/test/SemaCXX/references.cpp b/test/SemaCXX/references.cpp
index 630f53f2839e..df8337bec82c 100644
--- a/test/SemaCXX/references.cpp
+++ b/test/SemaCXX/references.cpp
@@ -102,3 +102,16 @@ string getInput();
void test9() {
string &s = getInput(); // expected-error{{lvalue reference}}
}
+
+void test10() {
+ __attribute((vector_size(16))) typedef int vec4;
+ typedef __attribute__(( ext_vector_type(4) )) int ext_vec4;
+
+ vec4 v;
+ int &a = v[0]; // expected-error{{non-const reference cannot bind to vector element}}
+ const int &b = v[0];
+
+ ext_vec4 ev;
+ int &c = ev.x; // expected-error{{non-const reference cannot bind to vector element}}
+ const int &d = ev.x;
+}
diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp
index da675609d123..f7ab80e67fd0 100644
--- a/test/SemaCXX/reinterpret-cast.cpp
+++ b/test/SemaCXX/reinterpret-cast.cpp
@@ -47,7 +47,7 @@ void constness()
// Invalid: T1 const* -> T2*
(void)reinterpret_cast<int*>(icp); // expected-error {{reinterpret_cast from 'int const *' to 'int *' casts away constness}}
// Invalid: T1*** -> T2 const* const**
- int const *const **icpcpp = reinterpret_cast<int const* const**>(ipppc); // expected-error {{reinterpret_cast from 'int ***const' to 'int const *const **' casts away constness}}
+ int const *const **icpcpp = reinterpret_cast<int const* const**>(ipppc); // expected-error {{reinterpret_cast from 'int ***' to 'int const *const **' casts away constness}}
// Valid: T1* -> T2*
int *ip = reinterpret_cast<int*>(icpcpp);
// Valid: T* -> T const*
diff --git a/test/SemaCXX/static-cast.cpp b/test/SemaCXX/static-cast.cpp
index cdaa843b8170..4818b041ad08 100644
--- a/test/SemaCXX/static-cast.cpp
+++ b/test/SemaCXX/static-cast.cpp
@@ -4,7 +4,7 @@ struct B : public A {}; // Single public base.
struct C1 : public virtual B {}; // Single virtual base.
struct C2 : public virtual B {};
struct D : public C1, public C2 {}; // Diamond
-struct E : private A {}; // Single private base. expected-note 3 {{'private' inheritance specifier here}}
+struct E : private A {}; // Single private base. expected-note 3 {{declared private here}}
struct F : public C1 {}; // Single path to B with virtual.
struct G1 : public B {};
struct G2 : public B {};
@@ -56,7 +56,7 @@ void t_529_2()
// Bad code below
(void)static_cast<void*>((const int*)0); // expected-error {{static_cast from 'int const *' to 'void *' is not allowed}}
- (void)static_cast<A*>((E*)0); // expected-error {{inaccessible base class 'struct A'}}
+ (void)static_cast<A*>((E*)0); // expected-error {{private base class 'struct A'}}
(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 'struct B **' to 'struct A **' is not allowed}}
@@ -86,8 +86,8 @@ void t_529_5_8()
(void)static_cast<D&>(*((A*)0)); // expected-error {{cannot cast 'struct A' to 'struct D &' via virtual base 'struct B'}}
(void)static_cast<B*>((const A*)0); // expected-error {{static_cast from 'struct A const *' to 'struct B *' casts away constness}}
(void)static_cast<B&>(*((const A*)0)); // expected-error {{static_cast from 'struct A const' to 'struct B &' casts away constness}}
- (void)static_cast<E*>((A*)0); // expected-error {{cannot cast 'struct A' to 'struct E' due to inaccessible}}
- (void)static_cast<E&>(*((A*)0)); // expected-error {{cannot cast 'struct A' to 'struct E' due to inaccessible}}
+ (void)static_cast<E*>((A*)0); // expected-error {{cannot cast private base class 'struct A' to 'struct E'}}
+ (void)static_cast<E&>(*((A*)0)); // expected-error {{cannot cast private base class 'struct A' to 'struct E'}}
(void)static_cast<H*>((A*)0); // expected-error {{ambiguous cast from base 'struct A' to derived 'struct 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 'struct A' to derived 'struct 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 'struct B *' to 'struct E *' is not allowed}}
@@ -178,3 +178,6 @@ struct X4 {
const X2 *x2;
};
+
+// PR5897 - accept static_cast from const void* to const int (*)[1].
+void PR5897() { (void)static_cast<const int(*)[1]>((const void*)0); }
diff --git a/test/SemaCXX/templated-friend-decl.cpp b/test/SemaCXX/templated-friend-decl.cpp
new file mode 100644
index 000000000000..c0034cd72f78
--- /dev/null
+++ b/test/SemaCXX/templated-friend-decl.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 %s
+
+template <typename T>
+struct Foo {
+ template <typename U>
+ struct Bar {};
+
+ // The templated declaration for class Bar should not be instantiated when
+ // Foo<int> is. This is to protect against PR5848; for now, this "parses" but
+ // requires a rewrite of the templated friend code to be properly fixed.
+ template <typename U>
+ friend struct Bar;
+};
+
+Foo<int> x;
diff --git a/test/SemaCXX/using-decl-1.cpp b/test/SemaCXX/using-decl-1.cpp
index e8a7d70976ec..30c4cfd997a1 100644
--- a/test/SemaCXX/using-decl-1.cpp
+++ b/test/SemaCXX/using-decl-1.cpp
@@ -60,3 +60,38 @@ namespace P {
g(f);
}
}
+
+// Make sure that ADL can find names brought in by using decls.
+namespace test0 {
+ namespace ns {
+ class Foo {};
+
+ namespace inner {
+ void foo(char *); // expected-note {{no known conversion}}
+ }
+
+ using inner::foo;
+ }
+
+ void test(ns::Foo *p) {
+ foo(*p); // expected-error {{no matching function for call to 'foo'}}
+ }
+}
+
+// Redeclarations!
+namespace test1 {
+ namespace ns0 { struct Foo {}; }
+ namespace A { void foo(ns0::Foo *p, int y, int z); }
+ namespace ns2 { using A::foo; }
+ namespace ns1 { struct Bar : ns0::Foo {}; }
+ namespace A { void foo(ns0::Foo *p, int y, int z = 0); } // expected-note {{candidate}}
+ namespace ns1 { using A::foo; }
+ namespace ns2 { struct Baz : ns1::Bar {}; }
+ namespace A { void foo(ns0::Foo *p, int y = 0, int z); }
+
+ void test(ns2::Baz *p) {
+ foo(p, 0, 0); // okay!
+ foo(p, 0); // should be fine!
+ foo(p); // expected-error {{no matching function}}
+ }
+}
diff --git a/test/SemaCXX/virtual-override.cpp b/test/SemaCXX/virtual-override.cpp
index 5e1e9b0899c6..09cbfadf9b37 100644
--- a/test/SemaCXX/virtual-override.cpp
+++ b/test/SemaCXX/virtual-override.cpp
@@ -29,14 +29,14 @@ class B : A {
namespace T3 {
struct a { };
-struct b : private a { }; // expected-note{{'private' inheritance specifier here}}
+struct b : private a { }; // expected-note{{declared private here}}
class A {
virtual a* f(); // expected-note{{overridden virtual function is here}}
};
class B : A {
- virtual b* f(); // expected-error{{return type of virtual function 'f' is not covariant with the return type of the function it overrides (conversion from 'struct T3::b' to inaccessible base class 'struct T3::a')}}
+ virtual b* f(); // expected-error{{invalid covariant return for virtual function: 'struct T3::a' is a private base class of 'struct T3::b'}}
};
}
@@ -215,6 +215,29 @@ namespace PR6110 {
Y1<Derived*, Base*> y;
}
+// Defer checking for covariance if either return type is dependent.
+namespace type_dependent_covariance {
+ struct B {};
+ template <int N> struct TD : public B {};
+ template <> struct TD<1> {};
+
+ template <int N> struct TB {};
+ struct D : public TB<0> {};
+
+ template <int N> struct X {
+ virtual B* f1(); // expected-note{{overridden virtual function is here}}
+ virtual TB<N>* f2(); // expected-note{{overridden virtual function is here}}
+ };
+ template <int N, int M> struct X1 : X<N> {
+ virtual TD<M>* f1(); // expected-error{{return type of virtual function 'f1' is not covariant with the return type of the function it overrides ('TD<1> *'}}
+ virtual D* f2(); // expected-error{{return type of virtual function 'f2' is not covariant with the return type of the function it overrides ('struct type_dependent_covariance::D *' is not derived from 'TB<1> *')}}
+ };
+
+ X1<0, 0> good;
+ X1<0, 1> bad_derived; // expected-note{{instantiation}}
+ X1<1, 0> bad_base; // expected-note{{instantiation}}
+}
+
namespace T10 {
struct A { };
struct B : A { };
diff --git a/test/SemaCXX/warn-missing-noreturn.cpp b/test/SemaCXX/warn-missing-noreturn.cpp
new file mode 100644
index 000000000000..32d020f15f3d
--- /dev/null
+++ b/test/SemaCXX/warn-missing-noreturn.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wmissing-noreturn
+void f() __attribute__((noreturn));
+
+template<typename T> void g(T) { // expected-warning {{function could be attribute 'noreturn'}}
+ f();
+}
+
+template void g<int>(int); // expected-note {{in instantiation of function template specialization 'g<int>' requested here}}
+
+template<typename T> struct A {
+ void g() { // expected-warning {{function could be attribute 'noreturn'}}
+ f();
+ }
+};
+
+template struct A<int>; // expected-note {{in instantiation of member function 'A<int>::g' requested here}}
+
+struct B {
+ template<typename T> void g(T) { // expected-warning {{function could be attribute 'noreturn'}}
+ f();
+ }
+};
+
+template void B::g<int>(int); // expected-note {{in instantiation of function template specialization 'B::g<int>' requested here}}
diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp
index 5620248f5005..3b5349a5ce1b 100644
--- a/test/SemaCXX/warn-unused-variables.cpp
+++ b/test/SemaCXX/warn-unused-variables.cpp
@@ -1,8 +1,7 @@
-// RUN: %clang -fsyntax-only -Wunused-variable -verify %s
-
+// RUN: %clang_cc1 -fsyntax-only -Wunused-variable -verify %s
template<typename T> void f() {
- T t;
- t = 17;
+ T t;
+ t = 17;
}
// PR5407
@@ -27,7 +26,7 @@ namespace PR5531 {
};
void test() {
- A();
+ A(); // expected-warning{{expression result unused}}
B(17);
C();
}
@@ -43,3 +42,12 @@ void bah() {
x.foo(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
x2->foo(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}}
}
+
+template<typename T>
+struct X0 { };
+
+template<typename T>
+void test_dependent_init(T *p) {
+ X0<int> i(p);
+ (void)i;
+}
diff --git a/test/SemaCXX/warn-weak-vtables.cpp b/test/SemaCXX/warn-weak-vtables.cpp
new file mode 100644
index 000000000000..1ea88a548e71
--- /dev/null
+++ b/test/SemaCXX/warn-weak-vtables.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -Wweak-vtables
+
+struct A { // expected-warning {{'A' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit}}
+ virtual void f() { }
+};
+
+template<typename T> struct B {
+ virtual void f() { }
+};
+
+namespace {
+ struct C {
+ virtual void f() { }
+ };
+}
+
+void f() {
+ struct A {
+ virtual void f() { }
+ };
+} \ No newline at end of file