This is an archive of the discontinued LLVM Phabricator instance.

[clang][parser] Allow GNU-style attributes in struct declarations
AbandonedPublic

Authored by tbaeder on Mar 24 2021, 9:41 AM.

Details

Summary

Sorry for the title, I'm not 100% sure that's even correct here.

This call to ProhibitAttributes() is dead code in the case of GNU-style attributes. They are needed in e.g. clang/test/Parser/objcbridge-related-attribute.m.

However, adding a && !getLangOpts().ObjC to the if statement just before is also not sufficient since clang expects to parse GNU-style attributes at this place without diagnosing them as well, for example in clang/test/Sema/struct-decl.c:71. This ends up diagnosing the wrongly-placed noreturn attribute at a later stage.

Once ProhibitAttributes() works with GNU-style attributes the cases mentioned above (and tons of other cases) are being diagnosed as incorrect.

This change depends on https://reviews.llvm.org/D97362 landing first.

Diff Detail

Event Timeline

tbaeder requested review of this revision.Mar 24 2021, 9:41 AM
tbaeder created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2021, 9:41 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder updated this revision to Diff 333226.Mar 25 2021, 12:50 AM

To be clear, this is expected to be an NFC change that allows D97362 to be applied without breaking bots? If so, it'd be helpful to have the changes as part of D97362 because they're critical to that review and so that we get appropriate CI pre-merge testing.

This (and https://reviews.llvm.org/D99338) are both NFC changes once https://reviews.llvm.org/D97362 lands (they need the three-parameter version of ProhibitCXX11Attributes()). I can merge the three into one patch if you prefer.

All the attribute patches are just preparations so I can finally enable the source locations in GNU attributes in https://reviews.llvm.org/D75844.

This (and https://reviews.llvm.org/D99338) are both NFC changes once https://reviews.llvm.org/D97362 lands (they need the three-parameter version of ProhibitCXX11Attributes()). I can merge the three into one patch if you prefer.

Thanks for verifying! I think they should probably be rolled up into one patch (it'd be easier for me to review in this case).