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

Yichi Lee via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 9 09:22:55 PDT 2023


yichi170 marked an inline comment as done.
yichi170 added inline comments.


================
Comment at: clang/docs/ReleaseNotes.rst:59
 --------------------
+- Improved ``__builtin_offsetof`` support, allowing qualified name in member designator. This fixes [Issue 64154](https://github.com/llvm/llvm-project/issues/64154).
 
----------------
aaron.ballman wrote:
> 
> 




================
Comment at: clang/test/SemaCXX/offsetof.cpp:106
+int x3[__builtin_offsetof(struct X2, X2::static_a) == 0 ? 1 : -1]; // expected-error{{no member named 'static_a'}}
+int x4[__builtin_offsetof(struct X2, X2::X2) == 0 ? 1 : -1]; // expected-error{{no member named 'X2'}}
+
----------------
aaron.ballman wrote:
> There's one more test I'd like to see:
> ```
> struct S {
>   int Foo;
> };
> 
> template <typename Ty>
> void func() {
>   static_assert(__builtin_offsetof(Ty, Ty::Foo) == 0, "");
> }
> 
> void inst() {
>   func<S>();
> }
> ```
It would get the compile error in the current patch, but I think it should be compiled without any error, right?


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