When declaring an anonymous struct with const or volatile
qualifiers, ensure the members of that anonymous struct are created with
that qualifier.
GCC behaves this way, and WG14 is currently discussing this behavior.
See also:
Differential D95408
[Sema][C] members of anonymous struct inherit QualType nickdesaulniers on Jan 25 2021, 4:20 PM. Authored by
Details
When declaring an anonymous struct with const or volatile GCC behaves this way, and WG14 is currently discussing this behavior. See also:
Diff Detail
Event Timeline
Comment Actions I know we don't have to deal with restrict because that qualifies a pointer (so there's no way to use it with an anonymous struct), but are there others? There's DeclSpec::TQ_unaligned (which has no corresponding qualifier in Qualifiers::TQ despite the comment about keeping them in sync). Similarly, what about: struct S { _Atomic struct { int i; }; } void foo(void) { struct S s; s.i = 12; // Is this an atomic assignment? } Further, do we have to worry about things which are not type specifiers but still impact the declaration, like various type attributes?
Comment Actions Prefer https://reviews.llvm.org/D125167.
|
Maybe there's a way to have Context.getTypeDeclType return the qualified type here? (I couldn't find a way, but only looked today).