diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-19 21:33:05 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-10-19 21:33:05 +0000 |
commit | 0706df40064d4d7559b4304af79d519033414b84 (patch) | |
tree | a746b692d4ae341fe5402dfc52efc808dd0c6aea /test/FixIt | |
parent | e7d7c39be90bf654a8da0f53f6682d965426d081 (diff) |
Improve the diagnostic when a comma ends up at the end of a declarator group
instead of a semicolon (as sometimes happens during refactorings). When such a
comma is seen at the end of a line, and is followed by something which can't
possibly be a declarator (or even something which might be a plausible typo for
a declarator), suggest that a semicolon was intended.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@142544 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/FixIt')
-rw-r--r-- | test/FixIt/fixit-cxx0x.cpp | 6 | ||||
-rw-r--r-- | test/FixIt/fixit.c | 7 | ||||
-rw-r--r-- | test/FixIt/fixit.cpp | 13 |
3 files changed, 26 insertions, 0 deletions
diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp index 73316457b1..9fb647d03f 100644 --- a/test/FixIt/fixit-cxx0x.cpp +++ b/test/FixIt/fixit-cxx0x.cpp @@ -52,3 +52,9 @@ namespace Constexpr { // -> constexpr static char *const p = 0; }; } + +namespace SemiCommaTypo { + int m {}, + n [[]], // expected-error {{expected ';' at end of declaration}} + int o; +} diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index 5ba0aac450..967ae23c18 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -70,3 +70,10 @@ void removeUnusedLabels(char c) { : c++; c = c + 3; L4: return; } + +int oopsAComma = 0, +void oopsMoreCommas() { + static int a[] = { 0, 1, 2 }, + static int b[] = { 3, 4, 5 }, + &a == &b ? oopsMoreCommas() : removeUnusedLabels(a[0]); +} diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp index 96ce2ce097..dff8a37820 100644 --- a/test/FixIt/fixit.cpp +++ b/test/FixIt/fixit.cpp @@ -111,3 +111,16 @@ void foo1() const {} // expected-error {{type qualifier is not allowed on this f void foo2() volatile {} // expected-error {{type qualifier is not allowed on this function}} void foo3() const volatile {} // expected-error {{type qualifier is not allowed on this function}} +struct S { void f(int, char); }; +int itsAComma, +itsAComma2 = 0, +oopsAComma(42), // expected-error {{expected ';' after declaration}} +AD oopsMoreCommas() { + static int n = 0, + static char c, + &d = c, // expected-error {{expected ';' after declaration}} + S s, // expected-error {{expected ';' after declaration}} + s.f(n, d); + AD ad, // expected-error {{expected ';' after declaration}} + return ad; +} |