public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Don't pushdecl compound literals inside C parameter scope (PR c/88701)
@ 2019-01-07 22:47 Jakub Jelinek
  2019-01-07 22:51 ` Joseph Myers
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2019-01-07 22:47 UTC (permalink / raw)
  To: Joseph S. Myers, Marek Polacek; +Cc: gcc-patches

Hi!

As reported recently, my commit to push block scope using pushdecl into
their corresponding scope broke compound literals appearing in parameter
scope.  For those, we can keep the previous behavior, where they stayed at
the function scope if they make it all the way there at all, the fix
was only needed for block scope compound literals and for those
current_function_decl is non-NULL.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2019-01-07  Jakub Jelinek  <jakub@redhat.com>

	PR c/88701
	* c-decl.c (build_compound_literal): If not TREE_STATIC, only pushdecl
	if current_function_decl is non-NULL.

	* gcc.dg/pr88701.c: New test.

--- gcc/c/c-decl.c.jj	2019-01-04 18:53:11.273323060 +0100
+++ gcc/c/c-decl.c	2019-01-07 13:30:23.108161124 +0100
@@ -5437,7 +5437,7 @@ build_compound_literal (location_t loc,
       pushdecl (decl);
       rest_of_decl_compilation (decl, 1, 0);
     }
-  else
+  else if (current_function_decl)
     pushdecl (decl);
 
   if (non_const)
--- gcc/testsuite/gcc.dg/pr88701.c.jj	2019-01-07 13:35:07.297528147 +0100
+++ gcc/testsuite/gcc.dg/pr88701.c	2019-01-07 13:34:42.237936686 +0100
@@ -0,0 +1,18 @@
+/* PR c/88701 */
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -pedantic-errors" } */
+
+void foo (int [(int (*)[1]) { 0 } == 0]);
+void bar (int n, int [(int (*)[n]) { 0 } == 0]);
+
+int
+baz (int a[(int (*)[1]) { 0 } == 0])
+{
+  return a[0];
+}
+
+int
+qux (int n, int a[(int (*)[n]) { 0 } == 0])
+{
+  return a[0] + n;
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Don't pushdecl compound literals inside C parameter scope (PR c/88701)
  2019-01-07 22:47 [PATCH] Don't pushdecl compound literals inside C parameter scope (PR c/88701) Jakub Jelinek
@ 2019-01-07 22:51 ` Joseph Myers
  0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2019-01-07 22:51 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Marek Polacek, gcc-patches

On Mon, 7 Jan 2019, Jakub Jelinek wrote:

> Hi!
> 
> As reported recently, my commit to push block scope using pushdecl into
> their corresponding scope broke compound literals appearing in parameter
> scope.  For those, we can keep the previous behavior, where they stayed at
> the function scope if they make it all the way there at all, the fix
> was only needed for block scope compound literals and for those
> current_function_decl is non-NULL.
> 
> 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-07 22:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 22:47 [PATCH] Don't pushdecl compound literals inside C parameter scope (PR c/88701) Jakub Jelinek
2019-01-07 22:51 ` 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).