summaryrefslogtreecommitdiffstats
path: root/test/FixIt
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2011-11-29 05:27:40 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2011-11-29 05:27:40 +0000
commit874d253668f9ed183ca409cdff9d424925ee7800 (patch)
tree637fc2dc1c9b792795c6f63d5cf68061c347caa2 /test/FixIt
parentb49e728a4d1a84b72f3aebf60ff494684f9cb004 (diff)
PR10101: Recover better from a common copy-paste error: if a function
declaration at namespace scope is followed by a semicolon and an open-brace (or in C++, a 'try', ':' or '='), then the error is probably a function definition with a spurious ';', rather than a mysterious '{'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145372 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/FixIt')
-rw-r--r--test/FixIt/fixit-cxx0x.cpp23
-rw-r--r--test/FixIt/fixit.c8
-rw-r--r--test/FixIt/fixit.cpp10
3 files changed, 41 insertions, 0 deletions
diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp
index 9fb647d03f..d9b8763b05 100644
--- a/test/FixIt/fixit-cxx0x.cpp
+++ b/test/FixIt/fixit-cxx0x.cpp
@@ -58,3 +58,26 @@ namespace SemiCommaTypo {
n [[]], // expected-error {{expected ';' at end of declaration}}
int o;
}
+
+int extraSemi(); // expected-error {{stray ';' in function definition}}
+ = delete;
+
+class ExtraSemi {
+public:
+ ExtraSemi();
+ ExtraSemi(const ExtraSemi &);
+ int n;
+};
+ExtraSemi::ExtraSemi(); // expected-error {{stray ';'}}
+ : n(0) {
+}
+ExtraSemi::ExtraSemi(const ExtraSemi &); // expected-error {{stray ';'}}
+ = default;
+
+template<typename T> T extraSemi(T t);
+
+template<typename T> T extraSemi(T t); // expected-error {{stray ';'}}
+{
+ return t;
+}
+template int extraSemi(int);
diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c
index 967ae23c18..da1144da0f 100644
--- a/test/FixIt/fixit.c
+++ b/test/FixIt/fixit.c
@@ -77,3 +77,11 @@ void oopsMoreCommas() {
static int b[] = { 3, 4, 5 },
&a == &b ? oopsMoreCommas() : removeUnusedLabels(a[0]);
}
+
+void extraSemicolon();
+{
+ void extraSemicolon();
+ {
+ return;
+ }
+}
diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp
index 86b397777c..7c8ba9ac6f 100644
--- a/test/FixIt/fixit.cpp
+++ b/test/FixIt/fixit.cpp
@@ -125,3 +125,13 @@ AD oopsMoreCommas() {
AD ad, // expected-error {{expected ';' at end of declaration}}
return ad;
}
+
+int extraSemi1(); // expected-error {{stray ';' in function definition}}
+{
+ return 0;
+}
+
+int extraSemi2(); // expected-error {{stray ';' in function definition}}
+try {
+} catch (...) {
+}