summaryrefslogtreecommitdiffstats
path: root/clang/test/Parser
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-07-23 05:45:25 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-07-23 05:45:25 +0000
commit87f5dc53b23ebe4dceb0a2354d83d96f07a1024e (patch)
treecb997819257dc6ee1b990bc5e335034f37455847 /clang/test/Parser
parent2694c05e8692fb95dbd9152a652394daa05d14a3 (diff)
downloadbcm5719-llvm-87f5dc53b23ebe4dceb0a2354d83d96f07a1024e.tar.gz
bcm5719-llvm-87f5dc53b23ebe4dceb0a2354d83d96f07a1024e.zip
Add diagnostics for comma at end of enum and for extra semicolon at namespace
scope to -Wc++11-extensions. Move extra semicolon after member function definition diagnostic out of -pedantic, since C++ allows a single semicolon there. Keep it in -Wextra-semi, though, since it's still questionable. llvm-svn: 160618
Diffstat (limited to 'clang/test/Parser')
-rw-r--r--clang/test/Parser/cxx-class.cpp6
-rw-r--r--clang/test/Parser/cxx-decl.cpp6
-rw-r--r--clang/test/Parser/cxx-extra-semi.cpp26
-rw-r--r--clang/test/Parser/cxx0x-decl.cpp13
4 files changed, 39 insertions, 12 deletions
diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp
index 75e3fbacc46..feccba85cf0 100644
--- a/clang/test/Parser/cxx-class.cpp
+++ b/clang/test/Parser/cxx-class.cpp
@@ -12,11 +12,15 @@ protected:
int : 1, : 2;
public:
+ void m0() {}; // ok, one extra ';' is permitted
+ void m1() {}
+ ; // ok, one extra ';' is permitted
void m() {
int l = 2;
- }; // expected-warning{{extra ';' after function definition}}
+ };; // expected-warning{{extra ';' after member function definition}}
template<typename T> void mt(T) { }
+ ;
; // expected-warning{{extra ';' inside a class}}
virtual int vf() const volatile = 0;
diff --git a/clang/test/Parser/cxx-decl.cpp b/clang/test/Parser/cxx-decl.cpp
index 57f33d826ff..951cd3dfd1e 100644
--- a/clang/test/Parser/cxx-decl.cpp
+++ b/clang/test/Parser/cxx-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic %s
int x(*g); // expected-error {{use of undeclared identifier 'g'}}
@@ -44,7 +44,7 @@ class asm_class_test {
void foo() __asm__("baz");
};
-enum { fooenum = 1 };
+enum { fooenum = 1, }; // expected-warning {{commas at the end of enumerator lists are a C++11 extension}}
struct a {
int Type : fooenum;
@@ -125,5 +125,3 @@ test6a { ;// expected-error {{C++ requires a type specifier for all declarations
// expected-error {{expected ';' after top level declarator}}
int test6b;
-
-
diff --git a/clang/test/Parser/cxx-extra-semi.cpp b/clang/test/Parser/cxx-extra-semi.cpp
index 35c886b63b2..2aa18dfcc0e 100644
--- a/clang/test/Parser/cxx-extra-semi.cpp
+++ b/clang/test/Parser/cxx-extra-semi.cpp
@@ -1,13 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -DPEDANTIC %s
// RUN: %clang_cc1 -fsyntax-only -Wextra-semi -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wextra-semi -verify -std=c++11 %s
// RUN: cp %s %t
// RUN: %clang_cc1 -x c++ -Wextra-semi -fixit %t
// RUN: %clang_cc1 -x c++ -Wextra-semi -Werror %t
class A {
void A1();
- void A2() { }; // expected-warning{{extra ';' after function definition}}
+ void A2() { };
+#ifndef PEDANTIC
+ // This warning is only produced if we specify -Wextra-semi, and not if only
+ // -pedantic is specified, since one semicolon is technically permitted.
+ // expected-warning@-4{{extra ';' after member function definition}}
+#endif
+ void A2b() { };; // expected-warning{{extra ';' after member function definition}}
; // expected-warning{{extra ';' inside a class}}
- void A3() { }; ;; // expected-warning{{extra ';' after function definition}}
+ void A2c() { }
+ ;
+#ifndef PEDANTIC
+ // expected-warning@-2{{extra ';' after member function definition}}
+#endif
+ void A3() { }; ;; // expected-warning{{extra ';' after member function definition}}
;;;;;;; // expected-warning{{extra ';' inside a class}}
; // expected-warning{{extra ';' inside a class}}
; ;; ; ;;; // expected-warning{{extra ';' inside a class}}
@@ -20,6 +33,9 @@ union B {
int a2;; // expected-warning{{extra ';' inside a union}}
};
-; // expected-warning{{extra ';' outside of a function}}
-; ;;// expected-warning{{extra ';' outside of a function}}
-
+;
+; ;;
+#if __cplusplus < 201103L
+// expected-warning@-3{{extra ';' outside of a function is a C++11 extension}}
+// expected-warning@-3{{extra ';' outside of a function is a C++11 extension}}
+#endif
diff --git a/clang/test/Parser/cxx0x-decl.cpp b/clang/test/Parser/cxx0x-decl.cpp
index b9f5141a531..9a220caa5ad 100644
--- a/clang/test/Parser/cxx0x-decl.cpp
+++ b/clang/test/Parser/cxx0x-decl.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -std=c++0x %s
+// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic %s
// Make sure we know these are legitimate commas and not typos for ';'.
namespace Commas {
@@ -8,7 +8,7 @@ namespace Commas {
}
struct S {};
-enum E { e };
+enum E { e, };
auto f() -> struct S {
return S();
@@ -16,3 +16,12 @@ auto f() -> struct S {
auto g() -> enum E {
return E();
}
+
+class ExtraSemiAfterMemFn {
+ // Due to a peculiarity in the C++11 grammar, a deleted or defaulted function
+ // is permitted to be followed by either one or two semicolons.
+ void f() = delete // expected-error {{expected ';' after delete}}
+ void g() = delete; // ok
+ void h() = delete;; // ok
+ void i() = delete;;; // expected-warning {{extra ';' after member function definition}}
+};
OpenPOWER on IntegriCloud