[PATCH] D133574: [C2x] reject type definitions in offsetof
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 27 04:40:13 PDT 2022
aaron.ballman added a comment.
In D133574#3816688 <https://reviews.llvm.org/D133574#3816688>, @inclyc wrote:
> This revision fixes:
>
> **anonymous struct**
>
>> You should be able to pass in the TagDecl directly because the diagnostics
>> engine knows how to print a NamedDecl.
>
> I've switch back to using `Context.getTagDeclType(New)` because this can print
> anonymous pretty.
>
> clang/test/C/C2x/n2350.c:23:29: error: 'struct (unnamed at clang/test/C/C2x/n2350.c:23:29)' cannot be defined in '__builtin_offsetof'
> return __builtin_offsetof(struct // expected-error-re{{'struct (unnamed at {{.*}})' cannot be defined in '__builtin_offsetof'}}
Thanks! I was very surprised we didn't print the anonymous decl properly from the decl itself, so it looks like we have the same bug in other places as well: https://godbolt.org/z/16vP3voTW
> **definitions within the second parameter**
>
> I've add a new test case for this. This bug is caused by the RAIIObject having
> incorrect scope.
Thanks!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133574/new/
https://reviews.llvm.org/D133574
More information about the cfe-commits
mailing list