On Wed, Feb 18, 2026 at 10:13:37AM +0100, Jakub Jelinek wrote: > Hi! > > Most other spots inthe C FE which change type of some VAR_DECL > through complete_array_type call relayout_decl to fix up DECL_MODE > etc., but build_compound_literal strangely does not. > > It has layout_decl (decl, 0); call later on but I think that is > quite useless given that already the build_decl call earlier > calls that and so the second layout_decl probably does nothing > most of the time. > > On the following testcase, the compound literal VAR_DECL has > BLKmode from the time it had incomplete array type and isn't > changed to DImode that the completed type has and asm stmt > expansion is unhappy about that. > > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, > ok for trunk?
OK. > 2026-02-17 Jakub Jelinek <[email protected]> > > PR c/123365 > * c-decl.cc (build_compound_literal): Call relayout_decl > after completing the type. > > * gcc.c-torture/compile/pr123365.c: New test. > > --- gcc/c/c-decl.cc.jj 2026-02-06 11:18:47.055640575 +0100 > +++ gcc/c/c-decl.cc 2026-02-17 18:38:08.807635169 +0100 > @@ -6541,6 +6541,7 @@ build_compound_literal (location_t loc, > > type = TREE_TYPE (decl); > TREE_TYPE (DECL_INITIAL (decl)) = type; > + relayout_decl (decl); > } > > if (type == error_mark_node || !COMPLETE_TYPE_P (type)) > --- gcc/testsuite/gcc.c-torture/compile/pr123365.c.jj 2026-02-17 > 18:42:47.169977786 +0100 > +++ gcc/testsuite/gcc.c-torture/compile/pr123365.c 2026-02-17 > 18:42:24.799352096 +0100 > @@ -0,0 +1,7 @@ > +/* PR c/123365 */ > + > +void > +foo () > +{ > + __asm__ volatile ("" : "+r" ((long long[]) { 0 })); > +} > > Jakub > Marek
