diff mbox

Only handle DECL_ABSTRACT_ORIGIN for fndecls in IPA (PR ipa/60457)

Message ID 20140310144740.GV22862@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek March 10, 2014, 2:47 p.m. UTC
Hi!

From the comments on gcc-patches and from what the then block does
I think only FUNCTION_DECLs were meant to be handled this way, but as the
testcase shows we can trigger it even with VAR_DECLs.

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

2014-03-10  Jakub Jelinek  <jakub@redhat.com>

	PR ipa/60457
	* ipa.c (symtab_remove_unreachable_nodes): Don't call
	cgraph_get_create_node on VAR_DECLs.

	* g++.dg/ipa/pr60457.C: New test.


	Jakub

Comments

Richard Biener March 10, 2014, 2:49 p.m. UTC | #1
On Mon, 10 Mar 2014, Jakub Jelinek wrote:

> Hi!
> 
> From the comments on gcc-patches and from what the then block does
> I think only FUNCTION_DECLs were meant to be handled this way, but as the
> testcase shows we can trigger it even with VAR_DECLs.
> 
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

> 2014-03-10  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR ipa/60457
> 	* ipa.c (symtab_remove_unreachable_nodes): Don't call
> 	cgraph_get_create_node on VAR_DECLs.
> 
> 	* g++.dg/ipa/pr60457.C: New test.
> 
> --- gcc/ipa.c.jj	2014-03-03 08:24:32.000000000 +0100
> +++ gcc/ipa.c	2014-03-07 17:27:20.193696625 +0100
> @@ -354,7 +354,8 @@ symtab_remove_unreachable_nodes (bool be
>  	node->aux = (void *)2;
>        else
>  	{
> -	  if (DECL_ABSTRACT_ORIGIN (node->decl))
> +	  if (TREE_CODE (node->decl) == FUNCTION_DECL
> +	      && DECL_ABSTRACT_ORIGIN (node->decl))
>  	    {
>  	      struct cgraph_node *origin_node
>  	      = cgraph_get_create_node (DECL_ABSTRACT_ORIGIN (node->decl));
> --- gcc/testsuite/g++.dg/ipa/pr60457.C.jj	2014-03-07 17:32:26.517037376 +0100
> +++ gcc/testsuite/g++.dg/ipa/pr60457.C	2014-03-07 17:32:10.000000000 +0100
> @@ -0,0 +1,17 @@
> +// PR ipa/60457
> +// { dg-do compile }
> +
> +template <class T>
> +struct A
> +{
> +};
> +
> +struct B : A <B>
> +{
> +  B ();
> +};
> +
> +B::B ()
> +{
> +  const int c[] = { 1, 1 };
> +}
> 
> 	Jakub
> 
>
diff mbox

Patch

--- gcc/ipa.c.jj	2014-03-03 08:24:32.000000000 +0100
+++ gcc/ipa.c	2014-03-07 17:27:20.193696625 +0100
@@ -354,7 +354,8 @@  symtab_remove_unreachable_nodes (bool be
 	node->aux = (void *)2;
       else
 	{
-	  if (DECL_ABSTRACT_ORIGIN (node->decl))
+	  if (TREE_CODE (node->decl) == FUNCTION_DECL
+	      && DECL_ABSTRACT_ORIGIN (node->decl))
 	    {
 	      struct cgraph_node *origin_node
 	      = cgraph_get_create_node (DECL_ABSTRACT_ORIGIN (node->decl));
--- gcc/testsuite/g++.dg/ipa/pr60457.C.jj	2014-03-07 17:32:26.517037376 +0100
+++ gcc/testsuite/g++.dg/ipa/pr60457.C	2014-03-07 17:32:10.000000000 +0100
@@ -0,0 +1,17 @@ 
+// PR ipa/60457
+// { dg-do compile }
+
+template <class T>
+struct A
+{
+};
+
+struct B : A <B>
+{
+  B ();
+};
+
+B::B ()
+{
+  const int c[] = { 1, 1 };
+}