summaryrefslogtreecommitdiffstats
path: root/test/SemaCXX
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/abstract.cpp9
-rw-r--r--test/SemaCXX/access-base-class.cpp2
-rw-r--r--test/SemaCXX/access-control-check.cpp2
-rw-r--r--test/SemaCXX/addr-of-overloaded-function.cpp32
-rw-r--r--test/SemaCXX/aggregate-initialization.cpp17
-rw-r--r--test/SemaCXX/anonymous-union.cpp2
-rw-r--r--test/SemaCXX/bitfield-layout.cpp30
-rw-r--r--test/SemaCXX/class-base-member-init.cpp23
-rw-r--r--test/SemaCXX/class.cpp2
-rw-r--r--test/SemaCXX/conditional-expr.cpp10
-rw-r--r--test/SemaCXX/constant-expression.cpp10
-rw-r--r--test/SemaCXX/constructor-initializer.cpp48
-rw-r--r--test/SemaCXX/conversion-function.cpp88
-rw-r--r--test/SemaCXX/copy-assignment.cpp2
-rw-r--r--test/SemaCXX/copy-initialization.cpp21
-rw-r--r--test/SemaCXX/cstyle-cast.cpp2
-rw-r--r--test/SemaCXX/default-assignment-operator.cpp22
-rw-r--r--test/SemaCXX/default-constructor-initializers.cpp6
-rw-r--r--test/SemaCXX/default1.cpp9
-rw-r--r--test/SemaCXX/default2.cpp3
-rw-r--r--test/SemaCXX/derived-to-base-ambig.cpp4
-rw-r--r--test/SemaCXX/direct-initializer.cpp2
-rw-r--r--test/SemaCXX/elaborated-type-specifier.cpp2
-rw-r--r--test/SemaCXX/exceptions.cpp23
-rw-r--r--test/SemaCXX/functional-cast.cpp2
-rw-r--r--test/SemaCXX/illegal-member-initialization.cpp6
-rw-r--r--test/SemaCXX/implicit-member-functions.cpp35
-rw-r--r--test/SemaCXX/inc-decrement-qualifiers.cpp9
-rw-r--r--test/SemaCXX/libstdcxx_is_pod_hack.cpp6
-rw-r--r--test/SemaCXX/libstdcxx_map_base_hack.cpp25
-rw-r--r--test/SemaCXX/local-classes.cpp9
-rw-r--r--test/SemaCXX/member-expr.cpp22
-rw-r--r--test/SemaCXX/member-location.cpp5
-rw-r--r--test/SemaCXX/member-pointer.cpp16
-rw-r--r--test/SemaCXX/missing-header.cpp9
-rw-r--r--test/SemaCXX/namespace-alias.cpp10
-rw-r--r--test/SemaCXX/nested-name-spec.cpp16
-rw-r--r--test/SemaCXX/new-delete.cpp23
-rw-r--r--test/SemaCXX/no-exceptions.cpp21
-rw-r--r--test/SemaCXX/offsetof.cpp37
-rw-r--r--test/SemaCXX/overload-call.cpp30
-rw-r--r--test/SemaCXX/overloaded-operator.cpp30
-rw-r--r--test/SemaCXX/qual-id-test.cpp6
-rw-r--r--test/SemaCXX/qualified-id-lookup.cpp22
-rw-r--r--test/SemaCXX/ref-init-ambiguous.cpp2
-rw-r--r--test/SemaCXX/references.cpp4
-rw-r--r--test/SemaCXX/static-cast.cpp2
-rw-r--r--test/SemaCXX/storage-class.cpp4
-rw-r--r--test/SemaCXX/typedef-redecl.cpp13
-rw-r--r--test/SemaCXX/typeid-ref.cpp12
-rw-r--r--test/SemaCXX/typeid.cpp1
-rw-r--r--test/SemaCXX/unused-functions.cpp8
-rw-r--r--test/SemaCXX/user-defined-conversions.cpp15
-rw-r--r--test/SemaCXX/value-initialization.cpp6
-rw-r--r--test/SemaCXX/virtual-override.cpp2
-rw-r--r--test/SemaCXX/warn-assignment-condition.cpp49
-rw-r--r--test/SemaCXX/warn-missing-noreturn.cpp14
-rw-r--r--test/SemaCXX/warn-reorder-ctor-initialization.cpp57
-rw-r--r--test/SemaCXX/warn-unused-parameters.cpp26
-rw-r--r--test/SemaCXX/warn-unused-variables.cpp8
-rw-r--r--test/SemaCXX/warn-weak-vtables.cpp2
61 files changed, 795 insertions, 140 deletions
diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp
index 0ae6c44..3e61cc3 100644
--- a/test/SemaCXX/abstract.cpp
+++ b/test/SemaCXX/abstract.cpp
@@ -42,11 +42,11 @@ void f() {
t3(C()); // expected-error {{allocation of an object of abstract type 'C'}}
}
-C e1[2]; // expected-error {{variable type 'C' is an abstract class}}
-C (*e2)[2]; // expected-error {{variable type 'C' is an abstract class}}
-C (**e3)[2]; // expected-error {{variable type 'C' is an abstract class}}
+C e1[2]; // expected-error {{array of abstract class type 'C'}}
+C (*e2)[2]; // expected-error {{array of abstract class type 'C'}}
+C (**e3)[2]; // expected-error {{array of abstract class type 'C'}}
-void t4(C c[2]); // expected-error {{parameter type 'C' is an abstract class}}
+void t4(C c[2]); // expected-error {{array of abstract class type 'C'}}
void t5(void (*)(C)); // expected-error {{parameter type 'C' is an abstract class}}
@@ -168,4 +168,3 @@ namespace PureImplicit {
struct D : C {};
D y;
}
-
diff --git a/test/SemaCXX/access-base-class.cpp b/test/SemaCXX/access-base-class.cpp
index 25fd9e5..8551690 100644
--- a/test/SemaCXX/access-base-class.cpp
+++ b/test/SemaCXX/access-base-class.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
namespace T1 {
class A { };
diff --git a/test/SemaCXX/access-control-check.cpp b/test/SemaCXX/access-control-check.cpp
index 1db6704..4540e99 100644
--- a/test/SemaCXX/access-control-check.cpp
+++ b/test/SemaCXX/access-control-check.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
class M {
int iM;
diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp
index 3b06119..f8b00df 100644
--- a/test/SemaCXX/addr-of-overloaded-function.cpp
+++ b/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -54,3 +54,35 @@ struct B
void d(void *);
static void d(A *);
};
+
+struct C {
+ C &getC() {
+ return makeAC; // expected-error{{address of overloaded function 'makeAC' cannot be converted to type 'C'}}
+ }
+
+ C &makeAC();
+ const C &makeAC() const;
+
+ static void f(); // expected-note{{candidate function}}
+ static void f(int); // expected-note{{candidate function}}
+
+ void g() {
+ int (&fp)() = f; // expected-error{{address of overloaded function 'f' does not match required type 'int ()'}}
+ }
+};
+
+// PR6886
+namespace test0 {
+ void myFunction(void (*)(void *));
+
+ class Foo {
+ void foo();
+
+ static void bar(void*);
+ static void bar();
+ };
+
+ void Foo::foo() {
+ myFunction(bar);
+ }
+}
diff --git a/test/SemaCXX/aggregate-initialization.cpp b/test/SemaCXX/aggregate-initialization.cpp
index 708a8f2..4c34447 100644
--- a/test/SemaCXX/aggregate-initialization.cpp
+++ b/test/SemaCXX/aggregate-initialization.cpp
@@ -60,10 +60,23 @@ struct C {
void f() {
A as1[1] = { };
- A as2[1] = { 1 }; // expected-error {{copying array element of type 'A' invokes deleted copy constructor}}
+ A as2[1] = { 1 }; // expected-error {{copying array element of type 'A' invokes deleted constructor}}
B b1 = { };
- B b2 = { 1 }; // expected-error {{copying member subobject of type 'A' invokes deleted copy constructor}}
+ B b2 = { 1 }; // expected-error {{copying member subobject of type 'A' invokes deleted constructor}}
C c1 = { 1 };
}
+
+class Agg {
+public:
+ int i, j;
+};
+
+class AggAgg {
+public:
+ Agg agg1;
+ Agg agg2;
+};
+
+AggAgg aggagg = { 1, 2, 3, 4 };
diff --git a/test/SemaCXX/anonymous-union.cpp b/test/SemaCXX/anonymous-union.cpp
index 0590db2..5c34e01 100644
--- a/test/SemaCXX/anonymous-union.cpp
+++ b/test/SemaCXX/anonymous-union.cpp
@@ -110,7 +110,7 @@ struct BadMembers {
};
// <rdar://problem/6481130>
-typedef union { }; // expected-error{{declaration does not declare anything}}
+typedef union { }; // expected-warning{{declaration does not declare anything}}
// <rdar://problem/7562438>
typedef struct objc_module *Foo ;
diff --git a/test/SemaCXX/bitfield-layout.cpp b/test/SemaCXX/bitfield-layout.cpp
new file mode 100644
index 0000000..adecf55
--- /dev/null
+++ b/test/SemaCXX/bitfield-layout.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -triple=x86_64-apple-darwin10
+
+#define CHECK_SIZE(name, size) extern int name##1[sizeof(name) == size ? 1 : -1];
+#define CHECK_ALIGN(name, size) extern int name##2[__alignof(name) == size ? 1 : -1];
+
+// Simple tests.
+struct Test1 {
+ char c : 9; // expected-warning {{size of bit-field 'c' (9 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+};
+CHECK_SIZE(Test1, 2);
+CHECK_ALIGN(Test1, 1);
+
+struct Test2 {
+ char c : 16; // expected-warning {{size of bit-field 'c' (16 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+};
+CHECK_SIZE(Test2, 2);
+CHECK_ALIGN(Test2, 2);
+
+struct Test3 {
+ char c : 32; // expected-warning {{size of bit-field 'c' (32 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+};
+CHECK_SIZE(Test3, 4);
+CHECK_ALIGN(Test3, 4);
+
+struct Test4 {
+ char c : 64; // expected-warning {{size of bit-field 'c' (64 bits) exceeds the size of its type; value will be truncated to 8 bits}}
+};
+CHECK_SIZE(Test4, 8);
+CHECK_ALIGN(Test4, 8);
+
diff --git a/test/SemaCXX/class-base-member-init.cpp b/test/SemaCXX/class-base-member-init.cpp
index 7095d92..ca9f045 100644
--- a/test/SemaCXX/class-base-member-init.cpp
+++ b/test/SemaCXX/class-base-member-init.cpp
@@ -51,3 +51,26 @@ namespace Test3 {
t(2) { } // expected-error {{multiple initializations given for non-static member 't'}}
};
}
+
+namespace test4 {
+ class A {
+ union {
+ struct {
+ int a;
+ int b;
+ };
+
+ int c;
+
+ union {
+ int d;
+ int e;
+ };
+ };
+
+ A(char _) : a(0), b(0) {}
+ A(short _) : a(0), c(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}}
+ A(int _) : d(0), e(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}}
+ A(long _) : a(0), d(0) {} // expected-error {{initializing multiple members of anonymous union}} expected-note {{previous initialization is here}}
+ };
+}
diff --git a/test/SemaCXX/class.cpp b/test/SemaCXX/class.cpp
index 508ca4d..7eea67a 100644
--- a/test/SemaCXX/class.cpp
+++ b/test/SemaCXX/class.cpp
@@ -103,7 +103,7 @@ void ogfn()
// PR3020: This used to crash due to double ownership of C4.
struct C4;
- C4; // expected-error {{declaration does not declare anything}}
+ C4; // expected-warning {{declaration does not declare anything}}
}
struct C4 {
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp
index 49bcd99..a812a59 100644
--- a/test/SemaCXX/conditional-expr.cpp
+++ b/test/SemaCXX/conditional-expr.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -faccess-control -std=c++0x -Wsign-compare %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++0x -Wsign-compare %s
// C++ rules for ?: are a lot stricter than C rules, and have to take into
// account more conversion options.
@@ -7,8 +7,7 @@
struct ToBool { explicit operator bool(); };
struct B;
-struct A { A(); A(const B&); }; // expected-note 2 {{candidate constructor}} \
- // expected-note 2 {{candidate is the implicit copy constructor}}
+struct A { A(); A(const B&); }; // expected-note 2 {{candidate constructor}}
struct B { operator A() const; }; // expected-note 2 {{candidate function}}
struct I { operator int(); };
struct J { operator I(); };
@@ -224,7 +223,7 @@ namespace PR6757 {
struct Foo3 {
Foo3();
- Foo3(Foo3&);
+ Foo3(Foo3&); // expected-note{{would lose const qualifier}}
};
struct Bar {
@@ -236,7 +235,6 @@ namespace PR6757 {
void f() {
(void)(true ? Bar() : Foo1()); // okay
(void)(true ? Bar() : Foo2()); // okay
- // FIXME: Diagnostic below could be improved
- (void)(true ? Bar() : Foo3()); // expected-error{{incompatible operand types ('PR6757::Bar' and 'PR6757::Foo3')}}
+ (void)(true ? Bar() : Foo3()); // expected-error{{no viable constructor copying temporary}}
}
}
diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp
index 0d4d387..a17dd58 100644
--- a/test/SemaCXX/constant-expression.cpp
+++ b/test/SemaCXX/constant-expression.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
-
// C++ [expr.const]p1:
// In several places, C++ requires expressions that evaluate to an integral
// or enumeration constant: as array bounds, as case expressions, as
@@ -79,5 +78,10 @@ template <int itval, Enum etval> struct C {
};
template struct C<1, eval>;
-//template struct C<cval, ceval>;
-//template struct C<Struct::sval, Struct::seval>;
+template struct C<cval, ceval>;
+template struct C<Struct::sval, Struct::seval>;
+
+enum {
+ a = sizeof(int) == 8,
+ b = a? 8 : 4
+};
diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp
index 96dfa8b..8e9e133 100644
--- a/test/SemaCXX/constructor-initializer.cpp
+++ b/test/SemaCXX/constructor-initializer.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -Wreorder -fsyntax-only -verify %s
class A {
int m;
+public:
A() : A::m(17) { } // expected-error {{member initializer 'm' does not name a non-static data member or base class}}
A(int);
};
@@ -72,8 +73,9 @@ 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}}
+ U() : a(1), // expected-note {{previous initialization is here}}
+ p(0), // expected-error {{initializing multiple members of anonymous union}}
+ d(1.0) {}
};
struct V {};
@@ -86,12 +88,11 @@ struct Derived : Base, Base1, virtual V {
struct Current : Derived {
int Derived;
- Current() : Derived(1), ::Derived(), // expected-warning {{member 'Derived' will be initialized after}} \
- // expected-note {{base '::Derived'}} \
- // expected-warning {{base class '::Derived' will be initialized after}}
+ Current() : Derived(1), ::Derived(), // expected-warning {{field 'Derived' will be initialized after base '::Derived'}} \
+ // expected-warning {{base class '::Derived' will be initialized after base 'Derived::V'}}
::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(), // expected-note {{base 'Derived::V'}}
+ 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}}
@@ -125,7 +126,7 @@ struct Q {
// A silly class used to demonstrate field-is-uninitialized in constructors with
// multiple params.
-class TwoInOne { TwoInOne(TwoInOne a, TwoInOne b) {} };
+class TwoInOne { public: TwoInOne(TwoInOne a, TwoInOne b) {} };
class InitializeUsingSelfTest {
bool A;
char* B;
@@ -170,3 +171,36 @@ struct X0 : NDC<int> {
NDC<int> ndc;
};
+
+namespace Test0 {
+
+struct A { A(); };
+
+struct B {
+ B() { }
+ const A a;
+};
+
+}
+
+namespace Test1 {
+ struct A {
+ enum Kind { Foo } Kind;
+ A() : Kind(Foo) {}
+ };
+}
+
+namespace Test2 {
+
+struct A {
+ A(const A&);
+};
+
+struct B : virtual A { };
+struct C : A, B { };
+
+C f(C c) {
+ return c;
+}
+
+}
diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp
index bca75c0..3e96d02 100644
--- a/test/SemaCXX/conversion-function.cpp
+++ b/test/SemaCXX/conversion-function.cpp
@@ -56,7 +56,7 @@ public:
// This used to crash Clang.
struct Flip;
-struct Flop { // expected-note{{candidate is the implicit copy constructor}}
+struct Flop {
Flop();
Flop(const Flip&); // expected-note{{candidate constructor}}
};
@@ -129,5 +129,89 @@ private:
};
A1 f() {
- return "Hello"; // expected-error{{invokes deleted copy constructor}}
+ return "Hello"; // expected-error{{invokes deleted constructor}}
+}
+
+namespace source_locations {
+ template<typename T>
+ struct sneaky_int {
+ typedef int type;
+ };
+
+ template<typename T, typename U>
+ struct A { };
+
+ template<typename T>
+ struct A<T, T> : A<T, int> { };
+
+ struct E {
+ template<typename T>
+ operator A<T, typename sneaky_int<T>::type>&() const; // expected-note{{candidate function}}
+ };
+
+ void f() {
+ A<float, float> &af = E(); // expected-error{{no viable conversion}}
+ A<float, int> &af2 = E();
+ const A<float, int> &caf2 = E();
+ }
+
+ // Check
+ template<typename T>
+ struct E2 {
+ operator T
+ * // expected-error{{pointer to a reference}}
+ () const;
+ };
+
+ E2<int&> e2i; // expected-note{{in instantiation}}
+}
+
+namespace crazy_declarators {
+ struct A {
+ (&operator bool())(); // expected-error {{must use a typedef to declare a conversion to 'bool (&)()'}}
+
+ // FIXME: This diagnostic is misleading (the correct spelling
+ // would be 'operator int*'), but it's a corner case of a
+ // rarely-used syntax extension.
+ *operator int(); // expected-error {{must use a typedef to declare a conversion to 'int *'}}
+ };
+}
+
+namespace smart_ptr {
+ class Y {
+ class YRef { };
+
+ Y(Y&);
+
+ public:
+ Y();
+ Y(YRef);
+
+ operator YRef(); // expected-note{{candidate function}}
+ };
+
+ struct X { // expected-note{{candidate constructor (the implicit copy constructor) not}}
+ explicit X(Y);
+ };
+
+ Y make_Y();
+
+ X f() {
+ X x = make_Y(); // expected-error{{no viable conversion from 'smart_ptr::Y' to 'smart_ptr::X'}}
+ X x2(make_Y());
+ return X(Y());
+ }
+}
+
+struct Any {
+ Any(...);
+};
+
+struct Other {
+ Other(const Other &);
+ Other();
+};
+
+void test_any() {
+ Any any = Other(); // expected-error{{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}}
}
diff --git a/test/SemaCXX/copy-assignment.cpp b/test/SemaCXX/copy-assignment.cpp
index 8cdb1be..bfe1501 100644
--- a/test/SemaCXX/copy-assignment.cpp
+++ b/test/SemaCXX/copy-assignment.cpp
@@ -94,6 +94,6 @@ void test() {
int i;
i = convertibleToInt;
- i = a; // expected-error{{incompatible type assigning 'A', expected 'int'}}
+ i = a; // expected-error{{assigning to 'int' from incompatible type 'A'}}
}
diff --git a/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp
index e5b1fd7..0c4aa96 100644
--- a/test/SemaCXX/copy-initialization.cpp
+++ b/test/SemaCXX/copy-initialization.cpp
@@ -1,18 +1,21 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
class X {
public:
- explicit X(const X&);
- X(int*); // expected-note 2{{candidate constructor}}
- explicit X(float*);
+ explicit X(const X&); // expected-note {{candidate constructor}}
+ X(int*); // expected-note 3{{candidate constructor}}
+ explicit X(float*); // expected-note {{candidate constructor}}
};
class Y : public X { };
void f(Y y, int *ip, float *fp) {
X x1 = y; // expected-error{{no matching constructor for initialization of 'X'}}
- X x2 = 0;
- X x3 = ip;
+ X x2 = 0; // expected-error{{no viable constructor copying variable}}
+ X x3 = ip; // expected-error{{no viable constructor copying variable}}
X x4 = fp; // expected-error{{no viable conversion}}
+ X x2a(0); // expected-error{{call to constructor of 'X' is ambiguous}}
+ X x3a(ip);
+ X x4a(fp);
}
struct foo {
@@ -25,19 +28,17 @@ void test(const foo *P) { P->bar(); } // expected-error{{cannot initialize objec
namespace PR6757 {
struct Foo {
Foo();
- Foo(Foo&);
+ Foo(Foo&); // expected-note{{candidate constructor not viable}}
};
struct Bar {
operator const Foo&() const;
};
- void f(Foo); // expected-note{{candidate function not viable: no known conversion from 'PR6757::Bar' to 'PR6757::Foo' for 1st argument}}
+ void f(Foo);
- // FIXME: This isn't really the right reason for the failure. We
- // should fail after overload resolution.
void g(Foo foo) {
- f(Bar()); // expected-error{{no matching function for call to 'f'}}
+ f(Bar()); // expected-error{{no viable constructor copying parameter of type 'PR6757::Foo const'}}
f(foo);
}
}
diff --git a/test/SemaCXX/cstyle-cast.cpp b/test/SemaCXX/cstyle-cast.cpp
index 6a28f4c..ccb25f0 100644
--- a/test/SemaCXX/cstyle-cast.cpp
+++ b/test/SemaCXX/cstyle-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -faccess-control %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A {};
diff --git a/test/SemaCXX/default-assignment-operator.cpp b/test/SemaCXX/default-assignment-operator.cpp
index baae03c..a04de37 100644
--- a/test/SemaCXX/default-assignment-operator.cpp
+++ b/test/SemaCXX/default-assignment-operator.cpp
@@ -1,13 +1,17 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-class Base { // expected-error {{cannot define the implicit default assignment operator for 'Base', because non-static reference member 'ref' can't use default assignment operator}}
- int &ref; // expected-note {{declared at}}
+class Base { // expected-error {{cannot define the implicit default assignment operator for 'Base', because non-static reference member 'ref' can't use default assignment operator}} \
+ // expected-warning{{class 'Base' does not declare any constructor to initialize its non-modifiable members}} \
+ // expected-note {{synthesized method is first required here}}
+ int &ref; // expected-note {{declared here}} \
+ // expected-note{{reference member 'ref' will never be initialized}}
};
-class X : Base { // // expected-error {{cannot define the implicit default assignment operator for 'X', because non-static const member 'cint' can't use default assignment operator}}
+class X : Base { // // expected-error {{cannot define the implicit default assignment operator for 'X', because non-static const member 'cint' can't use default assignment operator}} \
+ // expected-note {{synthesized method is first required here}}
public:
X();
- const int cint; // expected-note {{declared at}}
+ const int cint; // expected-note {{declared here}}
};
struct Y : X {
@@ -25,7 +29,7 @@ Z z2;
// Test1
void f(X x, const X cx) {
- x = cx; // expected-note 2 {{synthesized method is first required here}}
+ x = cx;
x = cx;
z1 = z2;
}
@@ -70,9 +74,11 @@ void i() {
// Test5
-class E1 { // expected-error{{cannot define the implicit default assignment operator for 'E1', because non-static const member 'a' can't use default assignment operator}}
+class E1 { // expected-error{{cannot define the implicit default assignment operator for 'E1', because non-static const member 'a' can't use default assignment operator}} \
+ // expected-note {{synthesized method is first required here}}
+
public:
- const int a; // expected-note{{declared at}}
+ const int a; // expected-note{{declared here}}
E1() : a(0) {}
};
@@ -80,6 +86,6 @@ public:
E1 e1, e2;
void j() {
- e1 = e2; // expected-note{{synthesized method is first required here}}
+ e1 = e2;
}
diff --git a/test/SemaCXX/default-constructor-initializers.cpp b/test/SemaCXX/default-constructor-initializers.cpp
index b40b133..757332d 100644
--- a/test/SemaCXX/default-constructor-initializers.cpp
+++ b/test/SemaCXX/default-constructor-initializers.cpp
@@ -16,7 +16,7 @@ X3 x3; // expected-note {{first required here}}
struct X4 { // expected-error {{must explicitly initialize the member 'x2'}} \
// expected-error {{must explicitly initialize the reference member 'rx2'}}
X2 x2; // expected-note {{member is declared here}}
- X2 & rx2; // expected-note {{declared at}}
+ X2 & rx2; // expected-note {{declared here}}
};
X4 x4; // expected-note {{first required here}}
@@ -46,8 +46,8 @@ Y4 y4;
struct Z1 { // expected-error {{must explicitly initialize the reference member 'z'}} \
// expected-error {{must explicitly initialize the const member 'c1'}}
- int& z; // expected-note {{declared at}}
- const int c1; // expected-note {{declared at}}
+ int& z; // expected-note {{declared here}}
+ const int c1; // expected-note {{declared here}}
volatile int v1;
};
diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp
index 790208a..e9d8a2f 100644
--- a/test/SemaCXX/default1.cpp
+++ b/test/SemaCXX/default1.cpp
@@ -14,7 +14,8 @@ void h(int i, int j = 2, int k = 3,
int n);// expected-error {{missing default argument on parameter 'n'}}
struct S { } s;
-void i(int = s) { } // expected-error {{no viable conversion}}
+void i(int = s) { } // expected-error {{no viable conversion}} \
+// expected-note{{passing argument to parameter here}}
struct X {
X(int);
@@ -26,6 +27,8 @@ struct Y { // expected-note 2{{candidate}}
explicit Y(int);
};
-void k(Y y = 17); // expected-error{{no viable conversion}}
+void k(Y y = 17); // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter 'y' here}}
-void kk(Y = 17); // expected-error{{no viable conversion}}
+void kk(Y = 17); // expected-error{{no viable conversion}} \
+// expected-note{{passing argument to parameter here}}
diff --git a/test/SemaCXX/default2.cpp b/test/SemaCXX/default2.cpp
index a0999c0..d9f1edf 100644
--- a/test/SemaCXX/default2.cpp
+++ b/test/SemaCXX/default2.cpp
@@ -102,7 +102,8 @@ void test_Z(const Z& z) {
struct ZZ {
static ZZ g(int = 17);
- void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}}
+ void f(ZZ z = g()); // expected-error{{no matching constructor for initialization}} \
+ // expected-note{{passing argument to parameter 'z' here}}
ZZ(ZZ&, int = 17); // expected-note{{candidate constructor}}
};
diff --git a/test/SemaCXX/derived-to-base-ambig.cpp b/test/SemaCXX/derived-to-base-ambig.cpp
index 9216e5b..129ec79 100644
--- a/test/SemaCXX/derived-to-base-ambig.cpp
+++ b/test/SemaCXX/derived-to-base-ambig.cpp
@@ -6,7 +6,7 @@ class D : public B, public C { };
void f(D* d) {
A* a;
- a = d; // expected-error{{ambiguous conversion from derived class 'D' to base class 'A':}} expected-error{{incompatible type assigning 'D *', expected 'A *'}}
+ a = d; // expected-error{{ambiguous conversion from derived class 'D' to base class 'A':}} expected-error{{assigning to 'A *' from incompatible type 'D *'}}
}
class Object2 { };
@@ -20,7 +20,7 @@ class F2 : public E2, public A2 { };
void g(E2* e2, F2* f2) {
Object2* o2;
o2 = e2;
- o2 = f2; // expected-error{{ambiguous conversion from derived class 'F2' to base class 'Object2':}} expected-error{{incompatible type assigning 'F2 *', expected 'Object2 *'}}
+ o2 = f2; // expected-error{{ambiguous conversion from derived class 'F2' to base class 'Object2':}} expected-error{{assigning to 'Object2 *' from incompatible type 'F2 *'}}
}
// Test that ambiguous/inaccessibility checking does not trigger too
diff --git a/test/SemaCXX/direct-initializer.cpp b/test/SemaCXX/direct-initializer.cpp
index d30642b..54cd6ca 100644
--- a/test/SemaCXX/direct-initializer.cpp
+++ b/test/SemaCXX/direct-initializer.cpp
@@ -10,7 +10,7 @@ void f() {
}
class Y {
- explicit Y(float);
+public: explicit Y(float);
};
class X { // expected-note{{candidate constructor (the implicit copy constructor)}}
diff --git a/test/SemaCXX/elaborated-type-specifier.cpp b/test/SemaCXX/elaborated-type-specifier.cpp
index 3cd3a1b..2d0b571 100644
--- a/test/SemaCXX/elaborated-type-specifier.cpp
+++ b/test/SemaCXX/elaborated-type-specifier.cpp
@@ -22,7 +22,7 @@ namespace NS {
void test_elab2(struct S4 *s4);
};
- void X::test_elab2(S4 *s4) { }
+ void X::test_elab2(S4 *s4) { } // expected-note{{passing argument to parameter 's4' here}}
}
void test_X_elab(NS::X x) {
diff --git a/test/SemaCXX/exceptions.cpp b/test/SemaCXX/exceptions.cpp
index 2ed4bfe..18349d1 100644
--- a/test/SemaCXX/exceptions.cpp
+++ b/test/SemaCXX/exceptions.cpp
@@ -97,3 +97,26 @@ BadReturn::BadReturn(int) try {
}
}
}
+
+// Cannot throw an abstract type.
+class foo {
+public:
+ foo() {}
+ void bar () {
+ throw *this; // expected-error{{cannot throw an object of abstract type 'foo'}}
+ }
+ virtual void test () = 0; // expected-note{{pure virtual function 'test'}}
+};
+
+namespace PR6831 {
+ namespace NA { struct S; }
+ namespace NB { struct S; }
+
+ void f() {
+ using namespace NA;
+ using namespace NB;
+ try {
+ } catch (int S) {
+ }
+ }
+}
diff --git a/test/SemaCXX/functional-cast.cpp b/test/SemaCXX/functional-cast.cpp
index 4e0486c..3b08864 100644
--- a/test/SemaCXX/functional-cast.cpp
+++ b/test/SemaCXX/functional-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -faccess-control %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
// ------------ not interpreted as C-style cast ------------
diff --git a/test/SemaCXX/illegal-member-initialization.cpp b/test/SemaCXX/illegal-member-initialization.cpp
index 3fb0b93..87069ef 100644
--- a/test/SemaCXX/illegal-member-initialization.cpp
+++ b/test/SemaCXX/illegal-member-initialization.cpp
@@ -14,9 +14,9 @@ struct X {
// expected-error {{constructor for 'X' must explicitly initialize the const member 'cvalue'}} \
// expected-error {{constructor for 'X' must explicitly initialize the reference member 'b'}} \
// expected-error {{constructor for 'X' must explicitly initialize the const member 'cb'}}
- int &value; // expected-note{{declared at}}
- const int cvalue; // expected-note{{declared at}}
- B& b; // expected-note{{declared at}}
+ int &value; // expected-note{{declared here}}
+ const int cvalue; // expected-note{{declared here}}
+ B& b; // expected-note{{declared here}}
const B cb; // expected-note{{declared here}}
};
diff --git a/test/SemaCXX/implicit-member-functions.cpp b/test/SemaCXX/implicit-member-functions.cpp
index 40a61e4..79cc367 100644
--- a/test/SemaCXX/implicit-member-functions.cpp
+++ b/test/SemaCXX/implicit-member-functions.cpp
@@ -1,14 +1,41 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-struct A { }; // expected-note {{previous implicit declaration is here}}
+struct A { };
A::A() { } // expected-error {{definition of implicitly declared constructor}}
-struct B { }; // expected-note {{previous implicit declaration is here}}
+struct B { };
B::B(const B&) { } // expected-error {{definition of implicitly declared copy constructor}}
-struct C { }; // expected-note {{previous implicit declaration is here}}
+struct C { };
C& C::operator=(const C&) { return *this; } // expected-error {{definition of implicitly declared copy assignment operator}}
-struct D { }; // expected-note {{previous implicit declaration is here}}
+struct D { };
D::~D() { } // expected-error {{definition of implicitly declared destructor}}
+// Make sure that the special member functions are introduced for
+// name-lookup purposes and overload with user-declared
+// constructors and assignment operators.
+namespace PR6570 {
+ class A { };
+
+ class B {
+ public:
+ B() {}
+
+ B(const A& a) {
+ operator = (CONST);
+ operator = (a);
+ }
+
+ B& operator = (const A& a) {
+ return *this;
+ }
+
+ void f(const A &a) {
+ B b(a);
+ };
+
+ static const B CONST;
+ };
+
+}
diff --git a/test/SemaCXX/inc-decrement-qualifiers.cpp b/test/SemaCXX/inc-decrement-qualifiers.cpp
new file mode 100644
index 0000000..ba837a9
--- /dev/null
+++ b/test/SemaCXX/inc-decrement-qualifiers.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+volatile int i;
+
+const int &inc = i++;
+const int &dec = i--;
+
+const int &incfail = ++i; // expected-error {{drops qualifiers}}
+const int &decfail = --i; // expected-error {{drops qualifiers}}
diff --git a/test/SemaCXX/libstdcxx_is_pod_hack.cpp b/test/SemaCXX/libstdcxx_is_pod_hack.cpp
index 7a4bebc..2e92032 100644
--- a/test/SemaCXX/libstdcxx_is_pod_hack.cpp
+++ b/test/SemaCXX/libstdcxx_is_pod_hack.cpp
@@ -1,5 +1,11 @@
// RUN: %clang_cc1 -fsyntax-only %s
+// This is a test for an egregious hack in Clang that works around
+// issues with GCC's evolution. libstdc++ 4.2.x uses __is_pod as an
+// identifier (to declare a struct template like the one below), while
+// GCC 4.3 and newer make __is_pod a keyword. Clang treats __is_pod as
+// a keyword *unless* it is introduced following the struct keyword.
+
template<typename T>
struct __is_pod {
};
diff --git a/test/SemaCXX/libstdcxx_map_base_hack.cpp b/test/SemaCXX/libstdcxx_map_base_hack.cpp
new file mode 100644
index 0000000..a556281
--- /dev/null
+++ b/test/SemaCXX/libstdcxx_map_base_hack.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only %s
+
+// libstdc++ 4.2.x contains a bug where a friend struct template
+// declaration for std::tr1::__detail::_Map base has different
+// template arguments than the real declaration. Clang has an
+// egregious hack to work around this problem, since we can't modify
+// all of the world's libstdc++'s.
+
+namespace std { namespace tr1 { namespace __detail {
+ template<typename _Key, typename _Value, typename _Ex, bool __unique,
+ typename _Hashtable>
+ struct _Map_base { };
+
+} } }
+
+namespace std { namespace tr1 {
+ template<typename T>
+ struct X1 {
+ template<typename _Key2, typename _Pair, typename _Hashtable>
+ friend struct __detail::_Map_base;
+ };
+
+} }
+
+std::tr1::X1<int> x1i;
diff --git a/test/SemaCXX/local-classes.cpp b/test/SemaCXX/local-classes.cpp
index 6799e58..500b219 100644
--- a/test/SemaCXX/local-classes.cpp
+++ b/test/SemaCXX/local-classes.cpp
@@ -30,3 +30,12 @@ namespace PR6383 {
compare_and_set2 (false, gross);
}
}
+
+namespace Templates {
+ template<int Value>
+ void f() {
+ struct Inner {
+ static int getValue() { return Value; }
+ };
+ }
+}
diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp
index 13ff64d..54a9593 100644
--- a/test/SemaCXX/member-expr.cpp
+++ b/test/SemaCXX/member-expr.cpp
@@ -2,7 +2,7 @@
class X{
public:
- enum E {Enumerator};
+ enum E {Enumerator}; // expected-note 2{{declared here}}
int f();
static int mem;
static float g();
@@ -11,8 +11,8 @@ public:
void test(X* xp, X x) {
int i1 = x.f();
int i2 = xp->f();
- x.E; // expected-error{{cannot refer to type member 'E' with '.'}}
- xp->E; // expected-error{{cannot refer to type member 'E' with '->'}}
+ x.E; // expected-error{{cannot refer to type member 'E' in 'X' with '.'}}
+ xp->E; // expected-error{{cannot refer to type member 'E' in 'X' with '->'}}
int i3 = x.Enumerator;
int i4 = xp->Enumerator;
x.mem = 1;
@@ -56,3 +56,19 @@ namespace test3 {
}
};
}
+
+namespace test4 {
+ class X {
+ protected:
+ template<typename T> void f(T);
+ };
+
+ class Y : public X {
+ public:
+ using X::f;
+ };
+
+ void test_f(Y y) {
+ y.f(17);
+ }
+}
diff --git a/test/SemaCXX/member-location.cpp b/test/SemaCXX/member-location.cpp
index c3099d2..6f7e1f5 100644
--- a/test/SemaCXX/member-location.cpp
+++ b/test/SemaCXX/member-location.cpp
@@ -1,5 +1,8 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// PR4103: Make sure we have a location for the error
-class A { float a(int *); int b(); };
+class A {
+ float a(int *); // expected-note{{passing argument to parameter here}}
+ int b();
+};
int A::b() { return a(a((int*)0)); } // expected-error {{cannot initialize a parameter of type 'int *' with an rvalue of type 'float'}}
diff --git a/test/SemaCXX/member-pointer.cpp b/test/SemaCXX/member-pointer.cpp
index 92ae92d..be25cbd 100644
--- a/test/SemaCXX/member-pointer.cpp
+++ b/test/SemaCXX/member-pointer.cpp
@@ -38,7 +38,7 @@ void f() {
int G::*pdig = pdi1; // expected-error {{conversion from pointer to member of class 'A' to pointer to member of class 'G' via virtual base 'D' is not allowed}}
// Conversion to member of base.
- pdi1 = pdid; // expected-error {{incompatible type assigning 'int D::*', expected 'int A::*'}}
+ pdi1 = pdid; // expected-error {{assigning to 'int A::*' from incompatible type 'int D::*'}}
// Comparisons
int (A::*pf2)(int, int);
@@ -88,7 +88,7 @@ void g() {
void (HasMembers::*pmd)() = &HasMembers::d;
}
-struct Incomplete;
+struct Incomplete; // expected-note {{forward declaration}}
void h() {
HasMembers hm, *phm = &hm;
@@ -123,7 +123,7 @@ void h() {
Incomplete *inc;
int Incomplete::*pii = 0;
- (void)(inc->*pii); // okay
+ (void)(inc->*pii); // expected-error {{pointer into incomplete}}
}
struct OverloadsPtrMem
@@ -147,3 +147,13 @@ namespace pr5985 {
}
};
}
+
+namespace pr6783 {
+ struct Base {};
+ struct X; // expected-note {{forward declaration}}
+
+ int test1(int Base::* p2m, X* object)
+ {
+ return object->*p2m; // expected-error {{left hand operand to ->*}}
+ }
+}
diff --git a/test/SemaCXX/missing-header.cpp b/test/SemaCXX/missing-header.cpp
new file mode 100644
index 0000000..f436579
--- /dev/null
+++ b/test/SemaCXX/missing-header.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "not exist" // expected-error{{'not exist' file not found}}
+
+class AnalysisContext {};
+static ControlFlowKind CheckFallThrough(AnalysisContext &AC) {
+ if (const AsmStmt *AS = dyn_cast<AsmStmt>(S)) {}
+ bool NoReturnEdge = false;
+}
diff --git a/test/SemaCXX/namespace-alias.cpp b/test/SemaCXX/namespace-alias.cpp
index 3ea1ccf..1c3da3c 100644
--- a/test/SemaCXX/namespace-alias.cpp
+++ b/test/SemaCXX/namespace-alias.cpp
@@ -91,3 +91,13 @@ namespace A = N;
A::X nx;
+namespace PR7014 {
+ namespace X
+ {
+ namespace Y {}
+ }
+
+ using namespace X;
+
+ namespace Y = X::Y;
+}
diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp
index 9a611c3..59a8e8c 100644
--- a/test/SemaCXX/nested-name-spec.cpp
+++ b/test/SemaCXX/nested-name-spec.cpp
@@ -13,9 +13,9 @@ namespace A {
}
A:: ; // expected-error {{expected unqualified-id}}
-// FIXME: redundant errors
-::A::ax::undef ex3; // expected-error {{no member named}} expected-error {{unknown type name}}
-A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}} expected-error {{unknown type name}}
+// FIXME: there is a member 'ax'; it's just not a class.
+::A::ax::undef ex3; // expected-error {{no member named 'ax'}}
+A::undef1::undef2 ex4; // expected-error {{no member named 'undef1'}}
int A::C::Ag1() { return 0; }
@@ -165,8 +165,7 @@ void ::global_func2(int) { } // expected-error{{definition or redeclaration of '
void N::f() { } // okay
struct Y; // expected-note{{forward declaration of 'Y'}}
-Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}} \
- // expected-error{{no type named 'foo' in}}
+Y::foo y; // expected-error{{incomplete type 'Y' named in nested name specifier}}
X::X() : a(5) { } // expected-error{{use of undeclared identifier 'X'}} \
// expected-error{{C++ requires a type specifier for all declarations}} \
@@ -195,7 +194,7 @@ somens::a a3 = a2; // expected-error {{no viable conversion}}
// typedefs and using declarations.
namespace test1 {
namespace ns {
- class Counter { static int count; };
+ class Counter { public: static int count; };
typedef Counter counter;
}
using ns::counter;
@@ -224,9 +223,8 @@ namespace test2 {
// PR6259, invalid case
namespace test3 {
- // FIXME: this should really only trigger once
- class A; // expected-note 2 {{forward declaration}}
+ class A; // expected-note {{forward declaration}}
void foo(const char *path) {
- A::execute(path); // expected-error 2 {{incomplete type 'test3::A' named in nested name specifier}}
+ A::execute(path); // expected-error {{incomplete type 'test3::A' named in nested name specifier}}
}
}
diff --git a/test/SemaCXX/new-delete.cpp b/test/SemaCXX/new-delete.cpp
index ae77e70..763ed2c 100644
--- a/test/SemaCXX/new-delete.cpp
+++ b/test/SemaCXX/new-delete.cpp
@@ -34,7 +34,6 @@ void good_news()
S *ps = new S(1, 2, 3.4);
ps = new (pf) (S)(1, 2, 3.4);
S *(*paps)[2] = new S*[*pi][2];
- ps = new (S[3])(1, 2, 3.4);
typedef int ia4[4];
ia4 *pai = new (int[3][4]);
pi = ::new int;
@@ -182,6 +181,7 @@ void f(X8 *x8) {
}
class X9 {
+public:
static void operator delete(void*, int); // expected-note {{'operator delete' declared here}}
static void operator delete(void*, float); // expected-note {{'operator delete' declared here}}
};
@@ -216,6 +216,7 @@ static void* f(void* g)
}
class X14 {
+public:
static void operator delete(void*, const size_t);
};
@@ -229,3 +230,23 @@ namespace PR5918 { // Look for template operator new overloads.
(void)new(0) S;
}
}
+
+namespace Test1 {
+
+void f() {
+ (void)new int[10](1, 2); // expected-error {{array 'new' cannot have initialization arguments}}
+}
+
+template<typename T>
+void g(unsigned i) {
+ (void)new T[1](i); // expected-error {{array 'new' cannot have initialization arguments}}
+}
+
+template<typename T>
+void h(unsigned i) {
+ (void)new T(i); // expected-error {{array 'new' cannot have initialization arguments}}
+}
+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}}
+
+}
diff --git a/test/SemaCXX/no-exceptions.cpp b/test/SemaCXX/no-exceptions.cpp
new file mode 100644
index 0000000..019e25c
--- /dev/null
+++ b/test/SemaCXX/no-exceptions.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Various tests for -fno-exceptions
+
+typedef __SIZE_TYPE__ size_t;
+
+namespace test0 {
+ // rdar://problem/7878149
+ class Foo {
+ public:
+ void* operator new(size_t x);
+ private:
+ void operator delete(void *x);
+ };
+
+ void test() {
+ // Under -fexceptions, this does access control for the associated
+ // 'operator delete'.
+ (void) new Foo();
+ }
+}
diff --git a/test/SemaCXX/offsetof.cpp b/test/SemaCXX/offsetof.cpp
index 3283270..47c3f22 100644
--- a/test/SemaCXX/offsetof.cpp
+++ b/test/SemaCXX/offsetof.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s -Winvalid-offsetof
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof
struct NonPOD {
virtual void f();
@@ -18,3 +18,38 @@ struct Derived : Base { int y; };
int o = __builtin_offsetof(Derived, x); // expected-warning{{offset of on non-POD type}}
const int o2 = sizeof(__builtin_offsetof(Derived, x));
+
+struct HasArray {
+ int array[17];
+};
+
+// Constant and non-constant offsetof expressions
+void test_ice(int i) {
+ int array0[__builtin_offsetof(HasArray, array[5])];
+ int array1[__builtin_offsetof(HasArray, array[i])]; // expected-error{{variable length arrays are not permitted in C++}}
+}
+
+// Bitfields
+struct has_bitfields {
+ int i : 7;
+ int j : 12; // expected-note{{bit-field is declared here}}
+};
+
+int test3 = __builtin_offsetof(struct has_bitfields, j); // expected-error{{cannot compute offset of bit-field 'j'}}
+
+// offsetof referring to members of a base class.
+struct Base1 {
+ int x;
+};
+
+struct Base2 {
+ int y;
+};
+
+struct Derived2 : public Base1, public Base2 {
+ int z;
+};
+
+int derived1[__builtin_offsetof(Derived2, x) == 0? 1 : -1];
+int derived2[__builtin_offsetof(Derived2, y) == 4? 1 : -1];
+int derived3[__builtin_offsetof(Derived2, z) == 8? 1 : -1];
diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp
index c286028..79c74ce 100644
--- a/test/SemaCXX/overload-call.cpp
+++ b/test/SemaCXX/overload-call.cpp
@@ -247,14 +247,14 @@ struct Z : X, Y { };
int& cvqual_subsume(X&); // expected-note{{candidate function}}
float& cvqual_subsume(const Y&); // expected-note{{candidate function}}
-int& cvqual_subsume2(const X&);
-float& cvqual_subsume2(const volatile Y&);
+int& cvqual_subsume2(const X&); // expected-note{{candidate function}}
+float& cvqual_subsume2(const volatile Y&); // expected-note{{candidate function}}
Z get_Z();
void cvqual_subsume_test(Z z) {
cvqual_subsume(z); // expected-error{{call to 'cvqual_subsume' is ambiguous; candidates are:}}
- int& x = cvqual_subsume2(get_Z()); // okay: only binds to the first one
+ int& x = cvqual_subsume2(get_Z()); // expected-error{{call to 'cvqual_subsume2' is ambiguous; candidates are:}}
}
// Test overloading with cv-qualification differences in reference
@@ -406,3 +406,27 @@ namespace PR6483 {
f1(x1); // expected-error{{no matching function for call}}
}
}
+
+namespace PR6078 {
+ struct A {
+ A(short); // expected-note{{candidate constructor}}
+ A(long); // expected-note{{candidate constructor}}
+ };
+ struct S {
+ typedef void ft(A);
+ operator ft*();
+ };
+
+ void f() {
+ S()(0); // expected-error{{conversion from 'int' to 'PR6078::A' is ambiguous}}
+ }
+}
+
+namespace PR6177 {
+ struct String { String(char const*); };
+
+ void f(bool const volatile&); // expected-note{{passing argument to parameter here}}
+ void f(String);
+
+ void g() { f(""); } // expected-error{{volatile lvalue reference to type 'bool const volatile' cannot bind to a value of unrelated type 'char const [1]'}}
+}
diff --git a/test/SemaCXX/overloaded-operator.cpp b/test/SemaCXX/overloaded-operator.cpp
index 89f1814..3d737f4 100644
--- a/test/SemaCXX/overloaded-operator.cpp
+++ b/test/SemaCXX/overloaded-operator.cpp
@@ -88,6 +88,7 @@ enum pr5244_bar
class pr5244_baz
{
+public:
pr5244_bar quux;
};
@@ -258,7 +259,7 @@ bool x(BB y, BB z) { return y != z; }
struct AX {
- AX& operator ->(); // expected-note {{declared at}}
+ AX& operator ->(); // expected-note {{declared here}}
int b;
};
@@ -268,14 +269,14 @@ void m() {
}
struct CircA {
- struct CircB& operator->(); // expected-note {{declared at}}
+ struct CircB& operator->(); // expected-note {{declared here}}
int val;
};
struct CircB {
- struct CircC& operator->(); // expected-note {{declared at}}
+ struct CircC& operator->(); // expected-note {{declared here}}
};
struct CircC {
- struct CircA& operator->(); // expected-note {{declared at}}
+ struct CircA& operator->(); // expected-note {{declared here}}
};
void circ() {
@@ -355,3 +356,24 @@ namespace pr5900 {
x(); // expected-error {{does not provide a call operator}}
}
}
+
+// Operator lookup through using declarations.
+namespace N {
+ struct X2 { };
+}
+
+namespace N2 {
+ namespace M {
+ namespace Inner {
+ template<typename T>
+ N::X2 &operator<<(N::X2&, const T&);
+ }
+ using Inner::operator<<;
+ }
+}
+
+void test_lookup_through_using() {
+ using namespace N2::M;
+ N::X2 x;
+ x << 17;
+}
diff --git a/test/SemaCXX/qual-id-test.cpp b/test/SemaCXX/qual-id-test.cpp
index 4846e72..e5c7306 100644
--- a/test/SemaCXX/qual-id-test.cpp
+++ b/test/SemaCXX/qual-id-test.cpp
@@ -48,7 +48,7 @@ namespace C
a.A::sub::x();
a.A::B::base::x();
- a.bad::x(); // expected-error{{type 'bad' is not a direct or virtual base of ''A::sub''}}
+ a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
a->foo();
a->member::foo();
@@ -69,7 +69,7 @@ namespace C
a->A::sub::x();
a->A::B::base::x();
- a->bad::x(); // expected-error{{type 'bad' is not a direct or virtual base of ''A::sub''}}
+ a->bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
(*a)->foo();
(*a)->member::foo();
@@ -107,7 +107,7 @@ namespace C
a.A::B::base::x();
a->A::member::foo();
- a.bad::x(); // expected-error{{direct or virtual}}
+ a.bad::x(); // expected-error{{'bad::x' is not a member of class 'A::sub'}}
}
void test_fun5() {
diff --git a/test/SemaCXX/qualified-id-lookup.cpp b/test/SemaCXX/qualified-id-lookup.cpp
index abde62e..dfb059a 100644
--- a/test/SemaCXX/qualified-id-lookup.cpp
+++ b/test/SemaCXX/qualified-id-lookup.cpp
@@ -124,3 +124,25 @@ namespace test1 {
template class ClassChecker<int>;
}
+
+namespace PR6830 {
+ namespace foo {
+
+ class X {
+ public:
+ X() {}
+ };
+
+ } // namespace foo
+
+ class Z {
+ public:
+ explicit Z(const foo::X& x) {}
+
+ void Work() {}
+ };
+
+ void Test() {
+ Z(foo::X()).Work();
+ }
+}
diff --git a/test/SemaCXX/ref-init-ambiguous.cpp b/test/SemaCXX/ref-init-ambiguous.cpp
index 8844162..a8e95a3 100644
--- a/test/SemaCXX/ref-init-ambiguous.cpp
+++ b/test/SemaCXX/ref-init-ambiguous.cpp
@@ -17,7 +17,7 @@ void test(C c) {
const E2 &e2 = c; // expected-error {{reference initialization of type 'E2 const &' with initializer of type 'C' is ambiguous}}
}
-void foo(const E2 &);
+void foo(const E2 &);// expected-note{{passing argument to parameter here}}
const E2 & re(C c) {
foo(c); // expected-error {{reference initialization of type 'E2 const &' with initializer of type 'C' is ambiguous}}
diff --git a/test/SemaCXX/references.cpp b/test/SemaCXX/references.cpp
index f1f4ab9..e40ea01 100644
--- a/test/SemaCXX/references.cpp
+++ b/test/SemaCXX/references.cpp
@@ -66,8 +66,8 @@ int& test6(int& x) {
int& not_initialized_error; // expected-error{{declaration of reference variable 'not_initialized_error' requires an initializer}}
extern int& not_initialized_okay;
-class Test6 {
- int& okay;
+class Test6 { // expected-warning{{class 'Test6' does not declare any constructor to initialize its non-modifiable members}}
+ int& okay; // expected-note{{reference member 'okay' will never be initialized}}
};
struct C : B, A { };
diff --git a/test/SemaCXX/static-cast.cpp b/test/SemaCXX/static-cast.cpp
index a5dd7e2..48f641a 100644
--- a/test/SemaCXX/static-cast.cpp
+++ b/test/SemaCXX/static-cast.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -faccess-control %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
struct A {};
struct B : public A {}; // Single public base.
struct C1 : public virtual B {}; // Single virtual base.
diff --git a/test/SemaCXX/storage-class.cpp b/test/SemaCXX/storage-class.cpp
new file mode 100644
index 0000000..a2e2063
--- /dev/null
+++ b/test/SemaCXX/storage-class.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+extern const int PR6495a = 42;
+extern int PR6495b = 42; // expected-warning{{'extern' variable has an initializer}}
+extern const int PR6495c[] = {42,43,44};
diff --git a/test/SemaCXX/typedef-redecl.cpp b/test/SemaCXX/typedef-redecl.cpp
index c382539..49e1f3a 100644
--- a/test/SemaCXX/typedef-redecl.cpp
+++ b/test/SemaCXX/typedef-redecl.cpp
@@ -13,7 +13,7 @@ struct X {
struct Y; // expected-note{{previous definition is here}}
typedef int Y; // expected-error{{typedef redefinition with different types ('int' vs 'Y')}}
-typedef int Y2; // expected-note{{previous definition is here}}
+typedef int Y2; // expected-note{{declared here}}
struct Y2; // expected-error{{definition of type 'Y2' conflicts with typedef of the same name}}
void f(); // expected-note{{previous definition is here}}
@@ -37,3 +37,14 @@ namespace test1 {
using namespace a;
foo x;
}
+
+namespace PR6923 {
+ struct A;
+
+ extern "C" {
+ struct A;
+ typedef struct A A;
+ }
+
+ struct A;
+}
diff --git a/test/SemaCXX/typeid-ref.cpp b/test/SemaCXX/typeid-ref.cpp
new file mode 100644
index 0000000..da00169
--- /dev/null
+++ b/test/SemaCXX/typeid-ref.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s
+namespace std {
+ class type_info;
+}
+
+struct X { };
+
+void f() {
+ // CHECK: @_ZTS1X = weak_odr constant
+ // CHECK: @_ZTI1X = weak_odr constant
+ (void)typeid(X&);
+}
diff --git a/test/SemaCXX/typeid.cpp b/test/SemaCXX/typeid.cpp
index 0e78ff4..8db7db5 100644
--- a/test/SemaCXX/typeid.cpp
+++ b/test/SemaCXX/typeid.cpp
@@ -5,7 +5,6 @@ void f()
(void)typeid(int); // expected-error {{error: you need to include <typeinfo> before using the 'typeid' operator}}
}
-// FIXME: This should really include <typeinfo>, but we don't have that yet.
namespace std {
class type_info;
}
diff --git a/test/SemaCXX/unused-functions.cpp b/test/SemaCXX/unused-functions.cpp
new file mode 100644
index 0000000..cefa9e1
--- /dev/null
+++ b/test/SemaCXX/unused-functions.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused -verify %s
+
+static int foo(int x) { return x; }
+
+template<typename T>
+T get_from_foo(T y) { return foo(y); }
+
+int g(int z) { return get_from_foo(z); }
diff --git a/test/SemaCXX/user-defined-conversions.cpp b/test/SemaCXX/user-defined-conversions.cpp
index 4367f4b..5de7f44 100644
--- a/test/SemaCXX/user-defined-conversions.cpp
+++ b/test/SemaCXX/user-defined-conversions.cpp
@@ -67,3 +67,18 @@ void test_conversion(ConvertibleToBase ctb, ConvertibleToDerived ctd,
Base b4(ctd);
Base b5 = ctfd;
}
+
+struct X1 {
+ X1(X1&); // expected-note{{candidate constructor not viable: no known conversion from 'X1' to 'X1 &' for 1st argument}}
+};
+
+struct X2 {
+ operator X1();
+};
+
+int &f(X1);
+float &f(...);
+
+void g(X2 b) {
+ int &ir = f(b); // expected-error{{no viable constructor copying parameter of type 'X1'}}
+}
diff --git a/test/SemaCXX/value-initialization.cpp b/test/SemaCXX/value-initialization.cpp
index 16a7a1d..10520fb 100644
--- a/test/SemaCXX/value-initialization.cpp
+++ b/test/SemaCXX/value-initialization.cpp
@@ -1,7 +1,9 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
-struct A { // expected-error {{implicit default constructor for 'A' must explicitly initialize the const member 'i'}}
- const int i; // expected-note {{declared at}}
+struct A { // expected-error {{implicit default constructor for 'A' must explicitly initialize the const member 'i'}} \
+ // expected-warning{{struct 'A' does not declare any constructor to initialize its non-modifiable members}}
+ const int i; // expected-note {{declared here}} \
+ // expected-note{{const member 'i' will never be initialized}}
virtual void f() { }
};
diff --git a/test/SemaCXX/virtual-override.cpp b/test/SemaCXX/virtual-override.cpp
index 6887135..e07531f 100644
--- a/test/SemaCXX/virtual-override.cpp
+++ b/test/SemaCXX/virtual-override.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -faccess-control -verify %s -std=c++0x
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x
namespace T1 {
class A {
diff --git a/test/SemaCXX/warn-assignment-condition.cpp b/test/SemaCXX/warn-assignment-condition.cpp
index ce16a68..e5a3425 100644
--- a/test/SemaCXX/warn-assignment-condition.cpp
+++ b/test/SemaCXX/warn-assignment-condition.cpp
@@ -12,33 +12,42 @@ void test() {
// With scalars.
if (x = 7) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
if ((x = 7)) {}
do {
} while (x = 7); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
do {
} while ((x = 7));
while (x = 7) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
+
while ((x = 7)) {}
for (; x = 7; ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
for (; (x = 7); ) {}
if (p = p) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
if ((p = p)) {}
do {
} while (p = p); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
do {
} while ((p = p));
while (p = p) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
while ((p = p)) {}
for (; p = p; ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
for (; (p = p); ) {}
// Initializing variables (shouldn't warn).
@@ -49,33 +58,41 @@ void test() {
// With temporaries.
if (x = (b+b).foo()) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
if ((x = (b+b).foo())) {}
do {
} while (x = (b+b).foo()); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
do {
} while ((x = (b+b).foo()));
while (x = (b+b).foo()) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
while ((x = (b+b).foo())) {}
for (; x = (b+b).foo(); ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
for (; (x = (b+b).foo()); ) {}
// With a user-defined operator.
if (a = b + b) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
if ((a = b + b)) {}
do {
} while (a = b + b); // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
do {
} while ((a = b + b));
while (a = b + b) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
while ((a = b + b)) {}
for (; a = b + b; ) {} // expected-warning {{using the result of an assignment as a condition without parentheses}} \
- // expected-note{{use '==' to turn this assignment into an equality comparison}}
+ // expected-note{{use '==' to turn this assignment into an equality comparison}} \
+ // expected-note{{place parentheses around the assignment to silence this warning}}
for (; (a = b + b); ) {}
}
diff --git a/test/SemaCXX/warn-missing-noreturn.cpp b/test/SemaCXX/warn-missing-noreturn.cpp
index 32d020f..8016c3d 100644
--- a/test/SemaCXX/warn-missing-noreturn.cpp
+++ b/test/SemaCXX/warn-missing-noreturn.cpp
@@ -22,3 +22,17 @@ struct B {
};
template void B::g<int>(int); // expected-note {{in instantiation of function template specialization 'B::g<int>' requested here}}
+
+// We don't want a warning here.
+struct X {
+ virtual void g() { f(); }
+};
+
+namespace test1 {
+ bool condition();
+
+ // We don't want a warning here.
+ void foo() {
+ while (condition()) {}
+ }
+}
diff --git a/test/SemaCXX/warn-reorder-ctor-initialization.cpp b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
index f419156..3ff01af 100644
--- a/test/SemaCXX/warn-reorder-ctor-initialization.cpp
+++ b/test/SemaCXX/warn-reorder-ctor-initialization.cpp
@@ -6,12 +6,13 @@ struct BB1 {};
class complex : public BB, BB1 {
public:
- complex() : s2(1), // expected-warning {{member 's2' will be initialized after}}
- s1(1) , // expected-note {{field s1}}
- s3(3), // expected-warning {{member 's3' will be initialized after}}
- BB1(), // expected-note {{base 'BB1'}} \
- // expected-warning {{base class 'BB1' will be initialized after}}
- BB() {} // expected-note {{base 'BB'}}
+ complex()
+ : s2(1), // expected-warning {{field 's2' will be initialized after field 's1'}}
+ s1(1),
+ s3(3), // expected-warning {{field 's3' will be initialized after base 'BB1'}}
+ BB1(), // expected-warning {{base class 'BB1' will be initialized after base 'BB'}}
+ BB()
+ {}
int s1;
int s2;
int s3;
@@ -44,14 +45,12 @@ struct C : public A, public B, private virtual V {
struct D : public A, public B {
- D() : A(), V() { } // expected-warning {{base class 'A' will be initialized after}} \
- // expected-note {{base 'V'}}
+ D() : A(), V() { } // expected-warning {{base class 'A' will be initialized after base 'V'}}
};
struct E : public A, public B, private virtual V {
- E() : A(), V() { } // expected-warning {{base class 'A' will be initialized after}} \
- // expected-note {{base 'V'}}
+ E() : A(), V() { } // expected-warning {{base class 'A' will be initialized after base 'V'}}
};
@@ -64,13 +63,11 @@ struct B1 {
};
struct F : public A1, public B1, private virtual V {
- F() : A1(), V() { } // expected-warning {{base class 'A1' will be initialized after}} \
- // expected-note {{base 'V'}}
+ F() : A1(), V() { } // expected-warning {{base class 'A1' will be initialized after base 'V'}}
};
struct X : public virtual A, virtual V, public virtual B {
- X(): A(), V(), B() {} // expected-warning {{base class 'A' will be initialized after}} \
- // expected-note {{base 'V'}}
+ X(): A(), V(), B() {} // expected-warning {{base class 'A' will be initialized after base 'V'}}
};
class Anon {
@@ -80,8 +77,8 @@ class Anon {
class Anon2 {
int c; union {int a,b;}; int d;
Anon2() : c(2),
- d(10), // expected-warning {{member 'd' will be initialized after}}
- b(1) {} // expected-note {{field b}}
+ d(10), // expected-warning {{field 'd' will be initialized after field 'b'}}
+ b(1) {}
};
class Anon3 {
union {int a,b;};
@@ -95,7 +92,31 @@ struct S2: virtual S1 { };
struct S3 { };
struct S4: virtual S3, S2 {
- S4() : S2(), // expected-warning {{base class 'T1::S2' will be initialized after}}
- S3() { }; // expected-note {{base 'T1::S3'}}
+ S4() : S2(), // expected-warning {{base class 'T1::S2' will be initialized after base 'T1::S3'}}
+ S3() { };
};
}
+
+namespace test2 {
+ struct Foo { Foo(); };
+ class A {
+ template <class T> A(T *t) :
+ y(), // expected-warning {{field 'y' will be initialized after field 'x'}}
+ x()
+ {}
+ Foo x;
+ Foo y;
+ };
+}
+
+// PR6575: this should not crash
+namespace test3 {
+ struct MyClass {
+ MyClass() : m_int(0) {}
+ union {
+ struct {
+ int m_int;
+ };
+ };
+ };
+}
diff --git a/test/SemaCXX/warn-unused-parameters.cpp b/test/SemaCXX/warn-unused-parameters.cpp
new file mode 100644
index 0000000..75d8dcc
--- /dev/null
+++ b/test/SemaCXX/warn-unused-parameters.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -Wunused-parameter -verify %s
+template<typename T>
+struct X {
+ T f0(T x);
+ T f1(T x);
+ T f2(T);
+ template<typename U> U f3(U x);
+ template<typename U> U f4(U x);
+ template<typename U> U f5(U);
+};
+
+template<typename T> T X<T>::f0(T x) { return x; }
+template<typename T> T X<T>::f1(T) { return T(); }
+template<typename T> T X<T>::f2(T x) { return T(); } // expected-warning{{unused parameter 'x'}}
+template<typename T> template<typename U> U X<T>::f3(U x) { return x; }
+template<typename T> template<typename U> U X<T>::f4(U) { return U(); }
+template<typename T> template<typename U> U X<T>::f5(U x) { return U(); } // expected-warning{{unused parameter 'x'}}
+
+void test_X(X<int> &x, int i) {
+ x.f0(i);
+ x.f1(i);
+ x.f2(i);
+ x.f3(i);
+ x.f4(i);
+ x.f5(i);
+}
diff --git a/test/SemaCXX/warn-unused-variables.cpp b/test/SemaCXX/warn-unused-variables.cpp
index 3b5349a..5ef7e70 100644
--- a/test/SemaCXX/warn-unused-variables.cpp
+++ b/test/SemaCXX/warn-unused-variables.cpp
@@ -51,3 +51,11 @@ void test_dependent_init(T *p) {
X0<int> i(p);
(void)i;
}
+
+namespace PR6948 {
+ template<typename T> class X;
+
+ void f() {
+ X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
+ }
+}
diff --git a/test/SemaCXX/warn-weak-vtables.cpp b/test/SemaCXX/warn-weak-vtables.cpp
index 1ea88a5..39333c1 100644
--- a/test/SemaCXX/warn-weak-vtables.cpp
+++ b/test/SemaCXX/warn-weak-vtables.cpp
@@ -18,4 +18,4 @@ void f() {
struct A {
virtual void f() { }
};
-} \ No newline at end of file
+}
OpenPOWER on IntegriCloud