[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 11 12:32:49 PDT 2023


cor3ntin added a comment.

@dblaikie Would you be willing to look at the debugger side of things in a subsequent patch? I'm not familiar with debug symbol code gen so I'm not sure I'd be able to improve thing the right way.



================
Comment at: clang/test/SemaCXX/cxx2c-placeholder-vars.cpp:2
+// RUN: %clang -cc1 -fsyntax-only -verify -std=c++2c -Wunused-parameter -Wunused %s
+
+void static_var() {
----------------
hubert.reinterpretcast wrote:
> hubert.reinterpretcast wrote:
> > hubert.reinterpretcast wrote:
> > > cor3ntin wrote:
> > > > cor3ntin wrote:
> > > > > cor3ntin wrote:
> > > > > > hubert.reinterpretcast wrote:
> > > > > > > hubert.reinterpretcast wrote:
> > > > > > > > hubert.reinterpretcast wrote:
> > > > > > > > > hubert.reinterpretcast wrote:
> > > > > > > > > > Can we have tests for:
> > > > > > > > > > ```
> > > > > > > > > > struct { int _, _; } a = { ._ = 0 };
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > and
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > struct A {
> > > > > > > > > >   A();
> > > > > > > > > >   int _, _;
> > > > > > > > > > };
> > > > > > > > > > 
> > > > > > > > > > A::A() : _(0) {}
> > > > > > > > > > ```
> > > > > > > > > Codegen test for
> > > > > > > > > ```
> > > > > > > > > static union { int _ = 42; };
> > > > > > > > > int &ref = _;
> > > > > > > > > int foo() { return 13; }
> > > > > > > > > static union { int _ = foo(); };
> > > > > > > > > int main(void) { return ref; }
> > > > > > > > > ```
> > > > > > > > > might be interesting.
> > > > > > > > > 
> > > > > > > > > I suspect that this case was missed in the committee discussion of the paper @cor3ntin.
> > > > > > > > Less controversial tests to consider:
> > > > > > > > ```
> > > > > > > > struct A {
> > > > > > > >   int _;
> > > > > > > >   union { int _; };
> > > > > > > > };
> > > > > > > > struct B { union { int _, _; }; };
> > > > > > > > ```
> > > > > > > > 
> > > > > > > In a similar vein, a codegen test for:
> > > > > > > ```
> > > > > > > struct A { A(); };
> > > > > > > inline void f [[gnu::used]]() {
> > > > > > >   static union { A _{}; };
> > > > > > >   static union { A _{}; };
> > > > > > > }
> > > > > > > ```
> > > > > > > 
> > > > > > > Perhaps not intended to be allowed though (premise was no symbols with "linkage"?)
> > > > > > What's interesting about 
> > > > > > 
> > > > > > ```
> > > > > > static union { int _ = 42; };
> > > > > > int &ref = _;
> > > > > > int foo() { return 13; }
> > > > > > static union { int _ = foo(); };
> > > > > > int main(void) { return ref; }
> > > > > > ```
> > > > > > ?
> > > > > > It's already supported by clang https://godbolt.org/z/6j89EdnEo
> > > > > > 
> > > > > > 
> > > > > > I'm adding the other tests (and fixing the associated bugs, of which there were a few...)
> > > > > > 
> > > > > > Perhaps not intended to be allowed though (premise was no symbols with "linkage"?)
> > > > > 
> > > > > 
> > > > > Yes, this should be ill-formed, anything where we would have to mangle  multiple `_` should be ill-formed.
> > > > > I do believe that's covered though, `_` does not have storage duration.
> > > > > What's interesting about 
> > > > > 
> > > > > ```
> > > > > static union { int _ = 42; };
> > > > > int &ref = _;
> > > > > int foo() { return 13; }
> > > > > static union { int _ = foo(); };
> > > > > int main(void) { return ref; }
> > > > > ```
> > > > > ?
> > > > > It's already supported by clang https://godbolt.org/z/6j89EdnEo
> > > > > 
> > > > > 
> > > > > I'm adding the other tests (and fixing the associated bugs, of which there were a few...)
> > > > > 
> > > > 
> > > > I see it now. Thanks, I hate it. There is apparently a preexisting bug.
> > > > And yes, i think we should say something about members of anonymous union declared at namespace scope in the standard.... I realize now this is missing
> > > > Thanks for catching that.
> > > > Thanks for catching that.
> > > 
> > > Glad to be of help!
> > > I do believe that's covered though, `_` does not have storage duration.
> > 
> > It's not covered by the wording: `_` //is// a non-static data member.
> > 
> > 
> @cor3ntin, it seems the designated initializer case has not been added.
Thanks for noticing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153536



More information about the cfe-commits mailing list