summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser
diff options
context:
space:
mode:
authorCharles Li <charles_li@playstation.sony.com>2016-04-14 23:47:07 +0000
committerCharles Li <charles_li@playstation.sony.com>2016-04-14 23:47:07 +0000
commit1a88adbb27a21e7728253c2f932b41009e314985 (patch)
tree7dafdd87f8d899c1dd638dcd2bc171df4ad58706 /clang/test/Parser
parent4960fbf391360ae04c5815fca2fd647567a977f3 (diff)
downloadbcm5719-llvm-1a88adbb27a21e7728253c2f932b41009e314985.tar.gz
bcm5719-llvm-1a88adbb27a21e7728253c2f932b41009e314985.zip
Lit C++11 Compatibility Patch #8
24 tests have been updated for C++11 compatibility. llvm-svn: 266387
Diffstat (limited to 'clang/test/Parser')
-rw-r--r--clang/test/Parser/cxx-class.cpp62
-rw-r--r--clang/test/Parser/cxx-decl.cpp52
-rw-r--r--clang/test/Parser/cxx-friend.cpp19
3 files changed, 113 insertions, 20 deletions
diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp
index 9e907f1b1c1..3cc006af23d 100644
--- a/clang/test/Parser/cxx-class.cpp
+++ b/clang/test/Parser/cxx-class.cpp
@@ -1,4 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions -std=c++11 %s
+
class C;
class C {
public:
@@ -69,11 +72,30 @@ public; // expected-error{{expected ':'}}
};
class F {
- int F1 { return 1; } // expected-error{{function definition does not declare parameters}}
- void F2 {} // expected-error{{function definition does not declare parameters}}
+ int F1 { return 1; }
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{function definition does not declare parameters}}
+#else
+ // expected-error@-4 {{expected expression}}
+ // expected-error@-5 {{expected}}
+ // expected-note@-6 {{to match this '{'}}
+ // expected-error@-7 {{expected ';' after class}}
+#endif
+
+ void F2 {}
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{function definition does not declare parameters}}
+#else
+ // expected-error@-4 {{variable has incomplete type 'void'}}
+ // expected-error@-5 {{expected ';' after top level declarator}}
+#endif
+
typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}}
typedef void F4() {} // expected-error{{function definition declared 'typedef'}}
};
+#if __cplusplus >= 201103L
+// expected-error@-2 {{extraneous closing brace}}
+#endif
namespace ctor_error {
class Foo {};
@@ -203,14 +225,38 @@ namespace BadFriend {
}
class PR20760_a {
- int a = ); // expected-warning {{extension}} expected-error {{expected expression}}
- int b = }; // expected-warning {{extension}} expected-error {{expected expression}}
- int c = ]; // expected-warning {{extension}} expected-error {{expected expression}}
+ int a = ); // expected-error {{expected expression}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
+ int b = }; // expected-error {{expected expression}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
+ int c = ]; // expected-error {{expected expression}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
};
class PR20760_b {
- int d = d); // expected-warning {{extension}} expected-error {{expected ';'}}
- int e = d]; // expected-warning {{extension}} expected-error {{expected ';'}}
- int f = d // expected-warning {{extension}} expected-error {{expected ';'}}
+ int d = d); // expected-error {{expected ';'}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
+ int e = d]; // expected-error {{expected ';'}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
+ int f = d // expected-error {{expected ';'}}
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
};
namespace PR20887 {
diff --git a/clang/test/Parser/cxx-decl.cpp b/clang/test/Parser/cxx-decl.cpp
index be79eb433fd..8a7a3886053 100644
--- a/clang/test/Parser/cxx-decl.cpp
+++ b/clang/test/Parser/cxx-decl.cpp
@@ -1,4 +1,6 @@
// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s
const char const *x10; // expected-error {{duplicate 'const' declaration specifier}}
@@ -46,7 +48,10 @@ class asm_class_test {
void foo() __asm__("baz");
};
-enum { fooenum = 1, }; // expected-error {{commas at the end of enumerator lists are a C++11 extension}}
+enum { fooenum = 1, };
+#if __cplusplus <= 199711L
+// expected-error@-2 {{commas at the end of enumerator lists are a C++11 extension}}
+#endif
struct a {
int Type : fooenum;
@@ -81,7 +86,11 @@ namespace Commas {
(global5),
*global6,
&global7 = global1,
- &&global8 = static_cast<int&&>(global1), // expected-error 2{{rvalue reference}}
+ &&global8 = static_cast<int&&>(global1),
+#if __cplusplus <= 199711L
+ // expected-error@-2 2{{rvalue references are a C++11 extension}}
+#endif
+
S::a,
global9,
global10 = 0,
@@ -185,7 +194,13 @@ namespace PR15017 {
}
// Ensure we produce at least some diagnostic for attributes in C++98.
-[[]] struct S; // expected-error 2{{}}
+[[]] struct S;
+#if __cplusplus <= 199711L
+// expected-error@-2 {{expected expression}}
+// expected-error@-3 {{expected unqualified-id}}
+#else
+// expected-error@-5 {{an attribute list cannot appear here}}
+#endif
namespace test7 {
struct Foo {
@@ -212,14 +227,20 @@ namespace PR5066 {
template<typename T> struct X {};
X<int N> x; // expected-error {{type-id cannot have a name}}
- using T = int (*T)(); // expected-error {{type-id cannot have a name}} expected-error {{C++11}}
+ using T = int (*T)(); // expected-error {{type-id cannot have a name}}
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{alias declarations are a C++11 extensio}}
+#endif
+
}
namespace PR17255 {
void foo() {
- typename A::template B<>; // expected-error {{use of undeclared identifier 'A'}} \
- // expected-error {{expected a qualified name after 'typename'}} \
- // expected-error {{'template' keyword outside of a template}}
+ typename A::template B<>; // expected-error {{use of undeclared identifier 'A'}}
+#if __cplusplus <= 199711L
+ // expected-error@-2 {{'template' keyword outside of a template}}
+#endif
+ // expected-error@-4 {{expected a qualified name after 'typename'}}
}
}
@@ -236,12 +257,25 @@ namespace DuplicateFriend {
struct A {
friend void friend f(); // expected-warning {{duplicate 'friend' declaration specifier}}
friend struct B friend; // expected-warning {{duplicate 'friend' declaration specifier}}
+#if __cplusplus >= 201103L
+ // expected-error@-2 {{'friend' must appear first in a non-function declaration}}
+#endif
};
}
// PR8380
extern "" // expected-error {{unknown linkage language}}
-test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \
- // expected-error {{expected ';' after top level declarator}}
+test6a { ;// expected-error {{C++ requires a type specifier for all declarations}}
+#if __cplusplus <= 199711L
+// expected-error@-2 {{expected ';' after top level declarator}}
+#else
+// expected-error@-4 {{expected expression}}
+// expected-note@-5 {{to match this}}
+#endif
int test6b;
+#if __cplusplus >= 201103L
+// expected-error@+3 {{expected}}
+// expected-error@-3 {{expected ';' after top level declarator}}
+#endif
+
diff --git a/clang/test/Parser/cxx-friend.cpp b/clang/test/Parser/cxx-friend.cpp
index ace0ff26e2d..a4492ba1a7a 100644
--- a/clang/test/Parser/cxx-friend.cpp
+++ b/clang/test/Parser/cxx-friend.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
class C {
friend class D;
@@ -21,9 +23,20 @@ class B {
// 'A' here should refer to the declaration above.
friend class A;
- friend C; // expected-warning {{specify 'class' to befriend}}
- friend U; // expected-warning {{specify 'union' to befriend}}
- friend int; // expected-warning {{non-class friend type 'int'}}
+ friend C;
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'class' to befriend 'C'}}
+#endif
+
+ friend U;
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'union' to befriend 'U'}}
+#endif
+
+ friend int;
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{non-class friend type 'int' is a C++11 extension}}
+#endif
friend void myfunc();
OpenPOWER on IntegriCloud