summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r--clang/test/SemaCXX/anonymous-struct.cpp23
-rw-r--r--clang/test/SemaCXX/class.cpp23
-rw-r--r--clang/test/SemaCXX/conversion-function.cpp29
-rw-r--r--clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp2
-rw-r--r--clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp2
-rw-r--r--clang/test/SemaCXX/exceptions.cpp23
-rw-r--r--clang/test/SemaCXX/qual-id-test.cpp18
-rw-r--r--clang/test/SemaCXX/unused.cpp12
-rw-r--r--clang/test/SemaCXX/warn-unused-value.cpp7
9 files changed, 118 insertions, 21 deletions
diff --git a/clang/test/SemaCXX/anonymous-struct.cpp b/clang/test/SemaCXX/anonymous-struct.cpp
index 1b5dc13cea0..b584f89ff44 100644
--- a/clang/test/SemaCXX/anonymous-struct.cpp
+++ b/clang/test/SemaCXX/anonymous-struct.cpp
@@ -1,7 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
struct S {
- S(); // expected-note {{because type 'S' has a user-provided default constructor}}
+ S();
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{because type 'S' has a user-provided default constructor}}
+#endif
};
struct { // expected-error {{anonymous structs and classes must be class members}}
@@ -9,15 +14,25 @@ struct { // expected-error {{anonymous structs and classes must be class members
struct E {
struct {
- S x; // expected-error {{anonymous struct member 'x' has a non-trivial constructor}}
+ S x;
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{anonymous struct member 'x' has a non-trivial constructor}}
+#endif
};
static struct {
};
};
template <class T> void foo(T);
-typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}} expected-note {{declared here}}
+typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}}
+#if __cplusplus <= 199711L
+// expected-note@-2 {{declared here}}
+#endif
+
void test() {
- foo(this); // expected-warning {{template argument uses unnamed type}}
+ foo(this);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{template argument uses unnamed type}}
+#endif
}
} A; // expected-error {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}}
diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp
index a6694403a68..a3593689b5f 100644
--- a/clang/test/SemaCXX/class.cpp
+++ b/clang/test/SemaCXX/class.cpp
@@ -1,7 +1,12 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s
class C {
public:
- auto int errx; // expected-error {{storage class specified for a member declaration}} expected-warning {{'auto' storage class specifier is redundant}}
+ auto int errx; // expected-error {{storage class specified for a member declaration}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{'auto' storage class specifier is redundant}}
+#else
+ // expected-warning@-4 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
+#endif
register int erry; // expected-error {{storage class specified for a member declaration}}
extern int errz; // expected-error {{storage class specified for a member declaration}}
@@ -36,12 +41,18 @@ public:
enum E1 { en1, en2 };
- int i = 0; // expected-warning {{in-class initialization of non-static data member is a C++11 extension}}
+ int i = 0;
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
static int si = 0; // expected-error {{non-const static data member must be initialized out of line}}
static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}}
static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}}
static const int vi = 0;
static const volatile int cvi = 0; // ok, illegal in C++11
+#if __cplusplus >= 201103L
+ // expected-error@-2 {{static const volatile data member must be initialized out of line}}
+#endif
static const E evi = 0;
void m() {
@@ -169,10 +180,18 @@ namespace rdar8066414 {
namespace rdar8367341 {
float foo();
+#if __cplusplus >= 201103L
+ // expected-note@-2 {{declared here}}
+#endif
struct A {
+#if __cplusplus <= 199711L
static const float x = 5.0f; // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}}
static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} expected-error {{in-class initializer for static data member is not a constant expression}}
+#else
+ static constexpr float x = 5.0f;
+ static constexpr float y = foo(); // expected-error {{constexpr variable 'y' must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo' cannot be used in a constant expression}}
+#endif
};
}
diff --git a/clang/test/SemaCXX/conversion-function.cpp b/clang/test/SemaCXX/conversion-function.cpp
index 649f6b4dce9..3f494cce8ce 100644
--- a/clang/test/SemaCXX/conversion-function.cpp
+++ b/clang/test/SemaCXX/conversion-function.cpp
@@ -1,4 +1,7 @@
// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++11 %s
+
class X {
public:
operator bool();
@@ -133,7 +136,12 @@ private:
A1 f() {
// FIXME: redundant diagnostics!
- return "Hello"; // expected-error {{calling a private constructor}} expected-warning {{an accessible copy constructor}}
+ return "Hello"; // expected-error {{calling a private constructor}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{an accessible copy constructor}}
+#else
+ // expected-warning@-4 {{copying parameter of type 'A1' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+#endif
}
namespace source_locations {
@@ -175,7 +183,13 @@ namespace crazy_declarators {
(&operator bool())(); // expected-error {{use a typedef to declare a conversion to 'bool (&)()'}}
*operator int(); // expected-error {{put the complete type after 'operator'}}
// No suggestion of using a typedef here; that's not possible.
- template<typename T> (&operator T())(); // expected-error-re {{cannot specify any part of a return type in the declaration of a conversion function{{$}}}}
+ template<typename T> (&operator T())();
+#if __cplusplus <= 199711L
+ // expected-error-re@-2 {{cannot specify any part of a return type in the declaration of a conversion function{{$}}}}
+#else
+ // expected-error-re@-4 {{cannot specify any part of a return type in the declaration of a conversion function; use an alias template to declare a conversion to 'T (&)()'{{$}}}}
+#endif
+
};
}
@@ -193,6 +207,10 @@ namespace smart_ptr {
};
struct X { // expected-note{{candidate constructor (the implicit copy constructor) not}}
+#if __cplusplus >= 201103L
+ // expected-note@-2 {{candidate constructor (the implicit move constructor) not}}
+#endif
+
explicit X(Y);
};
@@ -215,7 +233,12 @@ struct 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}}
+ Any any = Other();
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}}
+#else
+ // expected-error@-4 {{cannot pass object of non-trivial type 'Other' through variadic constructor; call will abort at runtime}}
+#endif
}
namespace PR7055 {
diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
index 1c59585b325..e2fbdfd6995 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11
+// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11
// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s
// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s -DCPP1Y
diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
index 787868fae17..1e5c98beb9c 100644
--- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wno-c++11-extensions -Wno-c++1y-extensions %s -DPRECXX11
+// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only -Wno-c++11-extensions -Wno-c++1y-extensions %s -DPRECXX11
// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s
// RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s
diff --git a/clang/test/SemaCXX/exceptions.cpp b/clang/test/SemaCXX/exceptions.cpp
index 9802a1a1d62..05793e2ffc8 100644
--- a/clang/test/SemaCXX/exceptions.cpp
+++ b/clang/test/SemaCXX/exceptions.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
struct A; // expected-note 4 {{forward declaration of 'A'}}
@@ -135,16 +137,29 @@ namespace Decay {
void f() throw (int*, int());
template<typename T> struct C {
- void f() throw (T); // expected-error {{pointer to incomplete type 'Decay::E' is not allowed in exception specification}}
+ void f() throw (T);
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{pointer to incomplete type 'Decay::E' is not allowed in exception specification}}
+#endif
};
struct D {
C<D[10]> c;
};
- struct E; // expected-note {{forward declaration}}
- C<E[10]> e; // expected-note {{in instantiation of}}
+ struct E;
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{forward declaration of 'Decay::E'}}
+#endif
+
+ C<E[10]> e;
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{in instantiation of template class 'Decay::C<Decay::E [10]>' requested here}}
+#endif
}
-void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}} expected-warning {{C++11}}
+void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{rvalue references are a C++11 extension}}
+#endif
namespace HandlerInversion {
struct B {};
diff --git a/clang/test/SemaCXX/qual-id-test.cpp b/clang/test/SemaCXX/qual-id-test.cpp
index 9994d75cac1..61e60ae82df 100644
--- a/clang/test/SemaCXX/qual-id-test.cpp
+++ b/clang/test/SemaCXX/qual-id-test.cpp
@@ -1,9 +1,15 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
namespace A
{
namespace B
{
- struct base // expected-note{{object type}}
+ struct base
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{lookup in the object type 'A::sub' refers here}}
+#endif
{
void x() {}
void y() {}
@@ -85,8 +91,14 @@ namespace C
void fun4a() {
A::sub *a;
- typedef A::member base; // expected-note{{current scope}}
- a->base::x(); // expected-error{{ambiguous}}
+ typedef A::member base;
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{lookup from the current scope refers here}}
+#endif
+ a->base::x();
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{lookup of 'base' in member access expression is ambiguous}}
+#endif
}
void fun4b() {
diff --git a/clang/test/SemaCXX/unused.cpp b/clang/test/SemaCXX/unused.cpp
index fbaf8c8bf3c..09a179e7bb8 100644
--- a/clang/test/SemaCXX/unused.cpp
+++ b/clang/test/SemaCXX/unused.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
// PR4103 : Make sure we don't get a bogus unused expression warning
namespace PR4103 {
@@ -28,8 +30,14 @@ namespace PR4103 {
namespace derefvolatile {
void f(volatile char* x) {
- *x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}}
- (void)*x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}}
+ *x;
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{expression result unused; assign into a variable to force a volatile load}}
+#endif
+ (void)*x;
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{expression result unused; assign into a variable to force a volatile load}}
+#endif
volatile char y = 10;
(void)y; // don't warn here, because it's a common pattern.
}
diff --git a/clang/test/SemaCXX/warn-unused-value.cpp b/clang/test/SemaCXX/warn-unused-value.cpp
index efabd506306..d6ec0fb5d1c 100644
--- a/clang/test/SemaCXX/warn-unused-value.cpp
+++ b/clang/test/SemaCXX/warn-unused-value.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++11 %s
// PR4806
namespace test0 {
@@ -12,7 +14,10 @@ namespace test0 {
// pointer to volatile has side effect (thus no warning)
Box* box = new Box;
box->i; // expected-warning {{expression result unused}}
- box->j; // expected-warning {{expression result unused}}
+ box->j;
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{expression result unused}}
+#endif
}
}
OpenPOWER on IntegriCloud