diff options
author | Alp Toker <alp@nuanti.com> | 2014-01-05 03:27:57 +0000 |
---|---|---|
committer | Alp Toker <alp@nuanti.com> | 2014-01-05 03:27:57 +0000 |
commit | be4a5ccb93f013cb7d20ded95b57d115b93130a7 (patch) | |
tree | 36c707f3a1956e74e277293253bbd0bc9e733bd1 /test/Parser | |
parent | c33eba892dd9ab6a2b233a7ed3aded1a102be876 (diff) | |
download | clang-be4a5ccb93f013cb7d20ded95b57d115b93130a7.tar.gz |
Fix bungled parse recovery in K&R function declarations
void knrNoSemi(i) int i { }
Adherents of The C Programming Language unfortunate enough to miss a semicolon
as above would be met with a cascade of errors spanning the remainder of the
TU.
This patch introduces a beautiful parse error recovery, complete with helpful
FixIt to restore sanity.
Before (output redacted for brevity):
error: 'error' diagnostics seen but not expected:
File declarators.c Line 119: declaration does not declare a parameter
File declarators.c Line 123: declaration does not declare a parameter
File declarators.c Line 127: parameter named 'func_E12' is missing
File declarators.c Line 127: expected ';' at end of declaration
File declarators.c Line 133: parameter named 'func_E13' is missing
File declarators.c Line 133: expected ';' at end of declaration
File declarators.c Line 139: parameter named 'func_E14' is missing
File declarators.c Line 139: expected ';' at end of declaration
File declarators.c Line 145: parameter named 'func_E15' is missing
File declarators.c Line 145: expected ';' at end of declaration
File declarators.c Line 150: expected function body after function declarator
File declarators.c Line 119: declaration of 'enum E11' will not be visible outside of this function
File declarators.c Line 123: declaration of 'enum E12' will not be visible outside of this function
File declarators.c Line 133: ISO C forbids forward references to 'enum' types
File declarators.c Line 133: declaration of 'enum E13' will not be visible outside of this function
File declarators.c Line 139: ISO C forbids forward references to 'enum' types
File declarators.c Line 139: declaration of 'enum E14' will not be visible outside of this function
File declarators.c Line 145: ISO C forbids forward references to 'enum' types
File declarators.c Line 145: declaration of 'enum E15' will not be visible outside of this function
...
After:
declarators.c:103:24: error: expected ';' at end of declaration
void knrNoSemi(i) int i { }
^
;
Patch found in a sealed envelope dated 1978 with the message "Do not open until
January 2014"
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198540 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser')
-rw-r--r-- | test/Parser/declarators.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c index f77c2d2192..39d9dc9449 100644 --- a/test/Parser/declarators.c +++ b/test/Parser/declarators.c @@ -100,6 +100,7 @@ long struct X { int x; } test15(); // expected-error {{'long struct' is invalid} void test16(i) int i j; { } // expected-error {{expected ';' at end of declaration}} void test17(i, j) int i, j k; { } // expected-error {{expected ';' at end of declaration}} +void knrNoSemi(i) int i { } // expected-error {{expected ';' at end of declaration}} // PR12595 |