[PATCH] D157201: [Clang] Support qualified name as member designator in offsetof

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 7 05:37:03 PDT 2023


cor3ntin added inline comments.


================
Comment at: clang/test/Sema/offsetof.c:79
+int x2[__builtin_offsetof(struct X2, X2::a) == 0 ? 1 : -1];
+int x3[__builtin_offsetof(struct X2, X2::X2) == 0 ? 1 : -1]; // expected-error{{no member named 'X2'}}
+
----------------
yichi170 wrote:
> Fznamznon wrote:
> > It probably makes sense to also add a test with static member of a class, like Aaron mentioned in GitHub - https://github.com/llvm/llvm-project/issues/64154#issuecomment-1653468938 .
> Hi @Fznamznon, I found that clang and clang++ output different errors with the following test.
> ```
> struct X2 { int a; static int static_a; };
> int x4[__builtin_offsetof(struct X2, X2::static_a) == 0 ? 1 : -1];
> // expected-error{{no member named 'static_a'}}
> ```
> C doesn't allow to have a static member in the struct, so is there any way to write the correct comment to make the test pass?
the tests should be in `test/SemaCXX/offsetof.cpp`, where you can use C++


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157201/new/

https://reviews.llvm.org/D157201



More information about the cfe-commits mailing list