llvm-project/clang/lib
Alp Toker eec8101b9b 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"

llvm-svn: 198540
2014-01-05 03:27:57 +00:00
..
ARCMigrate Replacing calls to getAttr with calls to hasAttr for clarity. No functional change intended -- this only replaces Boolean uses of getAttr. 2013-12-19 02:39:40 +00:00
AST Only mark dump() function definitions 'used' in debug builds 2014-01-04 13:47:14 +00:00
ASTMatchers [CMake] clang/lib: Prune redundant dependencies. 2013-12-10 02:36:22 +00:00
Analysis Only mark dump() function definitions 'used' in debug builds 2014-01-04 13:47:14 +00:00
Basic Only mark dump() function definitions 'used' in debug builds 2014-01-04 13:47:14 +00:00
CodeGen [ms-cxxabi] Improve vbtable name mangling accuracy 2014-01-03 23:42:00 +00:00
Driver Remove a tab that snuck in. 2014-01-02 15:34:59 +00:00
Edit Add front-end infrastructure now address space casts are in LLVM IR. 2013-12-11 13:39:46 +00:00
Format clang-format: Recognize single-line macro usages inside macros. 2014-01-03 11:50:46 +00:00
Frontend Move MS predefined type_info out of InitializePredefinedMacros 2014-01-04 15:25:02 +00:00
FrontendTool Bury leaked pointers in a global array to silence a leak detector in --disable-free mode 2013-12-27 08:11:08 +00:00
Headers [CMake][VS][XCode] Restruct the output directory layout more comfortable, ${BINARY_DIR}/${BUILD_MODE}/(bin|lib) 2013-12-30 06:48:30 +00:00
Index [CMake] clang/lib: Satisfy dependencies to add *actually used* libraries on target_link_libraries() and LLVM_LINK_COMPONENTS. 2013-12-09 19:04:43 +00:00
Lex Switch over more of the parser to err_expected 2013-12-30 23:29:50 +00:00
Parse Fix bungled parse recovery in K&R function declarations 2014-01-05 03:27:57 +00:00
Rewrite Implement MSVC header search algorithm in MicrosoftMode. 2013-12-27 19:46:16 +00:00
Sema Move MS predefined type_info out of InitializePredefinedMacros 2014-01-04 15:25:02 +00:00
Serialization [objc] Refactor and improve functionality for the -Wunused-property-ivar warning. 2014-01-03 18:32:18 +00:00
StaticAnalyzer Only mark dump() function definitions 'used' in debug builds 2014-01-04 13:47:14 +00:00
Tooling CompilationDatabase.cpp:stripPositionalArgs(): Match not "no-integrated-as" but "-no-integrated-as", it really fixes r197229. 2013-12-14 06:03:28 +00:00
CMakeLists.txt Fix dependencies now that the ARC migrator depends on the static analyzer. 2013-08-22 15:50:02 +00:00
Makefile Fix dependencies now that the ARC migrator depends on the static analyzer. 2013-08-22 15:50:02 +00:00