Parser TODO/FIXME

I have included a patch file for a few of the TODO/FIXME items in Parser.cpp . Two of the elements are pretty straightforward. The last which enforces a warning for a top level declaration of the form x; is labeled as a warning for C99 only. I however have checked that this warning is generated in c89 mode under gcc as well. So I added the diagnostic at the WARNING rather than EXTENSION level and omitted getLang().C99 in the test for emitting the diagnostic. Feel free to make any suggestions.
Patrick

patch1.diff (2.57 KB)

I have included a patch file for a few of the TODO/FIXME items in Parser.cpp . Two of the elements are pretty straightforward.

Looks great! A couple of nit-picky details :slight_smile:

case tok::kw___extension__: {
ConsumeToken();

  • // FIXME: Disable extension warnings.
  • bool warnings = Diags.getWarnOnExtensions();
  • Diags.setWarnOnExtensions(false);
    DeclTy *RV = ParseExternalDeclaration();
  • // FIXME: Restore extension warnings.
  • Diags.setWarnOnExtensions(warnings);
    return RV;

This looks good. There are several other places that handle extension which could use similar treatment.

  • virtual void ParseTopLevelSemi(SourceLocation SemiLoca){
  • }

Please put spaces before the opening brace, like:

  • virtual void ParseTopLevelSemi(SourceLocation SemiLoca) {
  • }

Also:

  • if(DS.getParsedSpecifiers() == 0){

should be:

  • if (DS.getParsedSpecifiers() == 0) {

Another thing, please remove the todo in: :slight_smile:

/// [!C99] init-declarator-list ‘;’ [TODO: warn in c99 mode]

The last which enforces a warning for a top level declaration of the form x; is labeled as a warning for C99 only. I however have checked that this warning is generated in c89 mode under gcc as well. So I added the diagnostic at the WARNING rather than EXTENSION level and omitted getLang().C99 in the test for emitting the diagnostic.

This is actually tricky. It’s important to mark it as an extension in C99 mode but a warning in C90 mode. We want this so that -pedantic -pedantic-errors will actually reject the code in C99 mode, but will still just emit a warning in C90 mode.

Unfortunately, this means that you have to add two diagnostics for the same message, one that is a warning and one that is an extension warning.

-Chris