This is an archive of the discontinued LLVM Phabricator instance.

[clang][parser] Allow GNU-style attributes in enum specifiers
AbandonedPublic

Authored by tbaeder on Mar 25 2021, 7:06 AM.

Details

Summary

We are parsing both C++11 and GNU-style attributes here, but the previous ProhibitAttributes() call was never working for GNU-style attributes.

GNU-style attributes are however expected to be parsed and not diagnosed, for example in clang/test/Sema/ast-print in the following code:

// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 *EnumWithAttributes2Ptr;
// expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
// expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked deprecated here}}
enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;

This is essentially the same as https://reviews.llvm.org/D99278 and needs https://reviews.llvm.org/D97362 to be applied first.

The comment just above this change is a bit confusing since it tries to explain that "an elaborated-type-specifier has a much more constrained grammar", but does not mention any attributes.

Diff Detail

Event Timeline

tbaeder requested review of this revision.Mar 25 2021, 7:06 AM
tbaeder created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 25 2021, 7:06 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
tbaeder updated this revision to Diff 333511.Mar 26 2021, 2:06 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.