* [C PATCH] Fix another compound literal ICE (PR c/89045)
@ 2019-01-28 22:36 Jakub Jelinek
2019-01-28 23:53 ` Joseph Myers
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2019-01-28 22:36 UTC (permalink / raw)
To: Joseph S. Myers, Marek Polacek; +Cc: gcc-patches
Hi!
In this case, when a compound literal is in the parameter scope of a nested
function, current_function_decl is non-NULL, but we still don't want to
pushdecl it, as the code doesn't expect any VAR_DECLs etc. in parameter
scope.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?
2019-01-28 Jakub Jelinek <jakub@redhat.com>
PR c/89045
* c-decl.c (build_compound_literal): Don't pushdecl if in parameter
scope.
* gcc.dg/pr89045.c: New test.
--- gcc/c/c-decl.c.jj 2019-01-27 12:55:16.714550950 +0100
+++ gcc/c/c-decl.c 2019-01-28 15:36:29.579811998 +0100
@@ -5512,7 +5512,7 @@ build_compound_literal (location_t loc,
pushdecl (decl);
rest_of_decl_compilation (decl, 1, 0);
}
- else if (current_function_decl)
+ else if (current_function_decl && !current_scope->parm_flag)
pushdecl (decl);
if (non_const)
--- gcc/testsuite/gcc.dg/pr89045.c.jj 2019-01-28 15:41:16.623104584 +0100
+++ gcc/testsuite/gcc.dg/pr89045.c 2019-01-28 15:43:18.333108582 +0100
@@ -0,0 +1,15 @@
+/* PR c/89045 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+int
+foo (int x)
+{
+ int v[(int){ x }];
+ v[0] = 0;
+ int bar (int p[(int){ x }])
+ {
+ return p[0];
+ }
+ return bar (v);
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [C PATCH] Fix another compound literal ICE (PR c/89045)
2019-01-28 22:36 [C PATCH] Fix another compound literal ICE (PR c/89045) Jakub Jelinek
@ 2019-01-28 23:53 ` Joseph Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2019-01-28 23:53 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Marek Polacek, gcc-patches
On Mon, 28 Jan 2019, Jakub Jelinek wrote:
> Hi!
>
> In this case, when a compound literal is in the parameter scope of a nested
> function, current_function_decl is non-NULL, but we still don't want to
> pushdecl it, as the code doesn't expect any VAR_DECLs etc. in parameter
> scope.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-28 23:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 22:36 [C PATCH] Fix another compound literal ICE (PR c/89045) Jakub Jelinek
2019-01-28 23:53 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).