diff mbox

Fix error recovery issue with alias

Message ID 686077088.b1Pk30ZbpY@polaris
State New
Headers show

Commit Message

Eric Botcazou June 25, 2013, 7:23 a.m. UTC
Hi,

this fixes a segfault on a malformed alias declaration, which is correctly 
flagged as an error by handle_alias_pairs:

error: 'Linker_Alias.Var' aliased to undefined symbol 'var2'

but is nevertheless later processed as a valid alias by the cgraph machinery.

Bootstrapped/regtested on x86_64-suse-linux, OK for the mainline?


2013-06-25  Eric Botcazou  <ebotcazou@adacore.com>

	* cgraphunit.c (handle_alias_pairs): Reset the alias flag after the
	error message is issued for an alias to an undefined symbol.


2013-06-25  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/specs/linker_alias.ads: New test.

Comments

Richard Biener Aug. 27, 2013, 7:46 a.m. UTC | #1
On Tue, Jun 25, 2013 at 9:23 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this fixes a segfault on a malformed alias declaration, which is correctly
> flagged as an error by handle_alias_pairs:
>
> error: 'Linker_Alias.Var' aliased to undefined symbol 'var2'
>
> but is nevertheless later processed as a valid alias by the cgraph machinery.
>
> Bootstrapped/regtested on x86_64-suse-linux, OK for the mainline?

Ok if it still applies.

Thanks,
Richard.

>
> 2013-06-25  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * cgraphunit.c (handle_alias_pairs): Reset the alias flag after the
>         error message is issued for an alias to an undefined symbol.
>
>
> 2013-06-25  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gnat.dg/specs/linker_alias.ads: New test.
>
>
> --
> Eric Botcazou
diff mbox

Patch

Index: cgraphunit.c
===================================================================
--- cgraphunit.c	(revision 200350)
+++ cgraphunit.c	(working copy)
@@ -1001,7 +1001,7 @@  analyze_functions (void)
 
 /* Translate the ugly representation of aliases as alias pairs into nice
    representation in callgraph.  We don't handle all cases yet,
-   unforutnately.  */
+   unfortunately.  */
 
 static void
 handle_alias_pairs (void)
@@ -1013,10 +1013,11 @@  handle_alias_pairs (void)
     {
       symtab_node target_node = symtab_node_for_asm (p->target);
 
-      /* Weakrefs with target not defined in current unit are easy to handle; they
-	 behave just as external variables except we need to note the alias flag
-	 to later output the weakref pseudo op into asm file.  */
-      if (!target_node && lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl)) != NULL)
+      /* Weakrefs with target not defined in current unit are easy to handle:
+	 they behave just as external variables except we need to note the
+	 alias flag to later output the weakref pseudo op into asm file.  */
+      if (!target_node
+	  && lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl)) != NULL)
 	{
 	  symtab_node node = symtab_get_node (p->decl);
 	  if (node)
@@ -1031,6 +1032,9 @@  handle_alias_pairs (void)
       else if (!target_node)
 	{
 	  error ("%q+D aliased to undefined symbol %qE", p->decl, p->target);
+	  symtab_node node = symtab_get_node (p->decl);
+	  if (node)
+	    node->symbol.alias = false;
 	  alias_pairs->unordered_remove (i);
 	  continue;
 	}