Improve the diagnostics generated for switch statements missing expressions
- Move the diagnostic to the case statement instead of at the end of the switch
- Add a fix-it hint as to how to fix the compilation error
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132903 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/Parser/switch-recovery.cpp b/test/Parser/switch-recovery.cpp
index 0e4dcfa..a1df426 100644
--- a/test/Parser/switch-recovery.cpp
+++ b/test/Parser/switch-recovery.cpp
@@ -156,3 +156,17 @@
}
}
}
+
+void missing_statement_case(int x) {
+ switch (x) {
+ case 1:
+ case 0: // expected-error {{label at end of compound statement: expected statement}}
+ }
+}
+
+void missing_statement_default(int x) {
+ switch (x) {
+ case 0:
+ default: // expected-error {{label at end of compound statement: expected statement}}
+ }
+}