diff options
| author | Richard Trieu <rtrieu@google.com> | 2015-05-12 21:36:35 +0000 |
|---|---|---|
| committer | Richard Trieu <rtrieu@google.com> | 2015-05-12 21:36:35 +0000 |
| commit | 1d3b58e317963882ce2314f153b3e315833fd04b (patch) | |
| tree | 992d1837e22db8caabc40b97be0c1adf0e31849b /clang/test/Parser | |
| parent | 08d7027cc1eb6ac8e9d54ab469e04b1f22a1d3c6 (diff) | |
| download | bcm5719-llvm-1d3b58e317963882ce2314f153b3e315833fd04b.tar.gz bcm5719-llvm-1d3b58e317963882ce2314f153b3e315833fd04b.zip | |
Add a new error for unexpected semi-colon before closing delimiter.
Previously, if a semi-colon is unexpectedly added before a closing ')', ']' or
'}', two errors and one note would emitted, and the parsing would get confused
to which scope it was in. This change consumes the semi-colon, recovers
parsing better, and emits only one error with a fix-it.
llvm-svn: 237192
Diffstat (limited to 'clang/test/Parser')
| -rw-r--r-- | clang/test/Parser/cxx-class.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Parser/extra-semi.cpp | 14 |
2 files changed, 17 insertions, 3 deletions
diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp index f46e752bcb0..38eef1756d0 100644 --- a/clang/test/Parser/cxx-class.cpp +++ b/clang/test/Parser/cxx-class.cpp @@ -210,9 +210,9 @@ class X2 { a::a; }; // expected-error {{undeclared identifier 'a'}} class BadExceptionSpec { void f() throw(int; // expected-error {{expected ')'}} expected-note {{to match}} - void g() throw( // expected-note {{to match}} - int( // expected-note {{to match}} - ; // expected-error 2{{expected ')'}} expected-error {{unexpected end of exception specification}} + void g() throw( + int( + ; // expected-error {{unexpected ';' before ')'}} )); }; diff --git a/clang/test/Parser/extra-semi.cpp b/clang/test/Parser/extra-semi.cpp new file mode 100644 index 00000000000..1a44dae411e --- /dev/null +++ b/clang/test/Parser/extra-semi.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: cp %s %t.cpp +// RUN: not %clang_cc1 -fsyntax-only %t.cpp -fixit +// RUN: %clang_cc1 -fsyntax-only %t.cpp + +void test1(int a;) { // expected-error{{unexpected ';' before ')'}} + while (a > 5;) {} // expected-error{{unexpected ';' before ')'}} + if (int b = 10;) {} // expected-error{{unexpected ';' before ')'}} + for (int c = 0; c < 21; ++c;) {} // expected-error{{unexpected ';' before ')'}} + int d = int(3 + 4;); // expected-error{{unexpected ';' before ')'}} + int e[5;]; // expected-error{{unexpected ';' before ']'}} + e[a+1;] = 4; // expected-error{{unexpected ';' before ']'}} + int f[] = {1,2,3;}; // expected-error{{unexpected ';' before '}'}} +} |

