]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR middle-end/51998
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 2 Feb 2012 13:29:31 +0000 (13:29 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 2 Feb 2012 13:29:31 +0000 (13:29 +0000)
* cgraphunit.c (cgraph_analyze_function): Break cyclic aliases.
* varpool.c (varpool_analyze_pending_decls): Likewise.

* testsuite/gcc.dg/alias-12.c: New testcase.
* testsuite/gcc.dg/alias-13.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183836 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/cgraphunit.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/alias-12.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/alias-13.c [new file with mode: 0644]
gcc/varpool.c

index c85aa65252710840848212d816027a6f99b3a139..9bb55173ed3fe4199e63be8a9ae0ce87cf66cb0c 100644 (file)
@@ -1,3 +1,10 @@
+2012-02-02 Jan Hubicka  <jh@suse.cz>
+          Tom de Vries  <tom@codesourcery.com>
+
+       PR middle-end/51998
+       * cgraphunit.c (cgraph_analyze_function): Break cyclic aliases.
+       * varpool.c (varpool_analyze_pending_decls): Likewise.
+
 2012-02-02  Sumanth G <sumanth.gundapaneni@kpitcummins.com>
            Jayant R Sonar <jayant.sonar@kpitcummins.com>
 
index 8f96d3859bf441f5f793a3bbde24ab63cd30b1d3..ddc026163ce0c0dd3922d7e6a01b5db96c6c7f84 100644 (file)
@@ -836,6 +836,16 @@ cgraph_analyze_function (struct cgraph_node *node)
   if (node->alias && node->thunk.alias)
     {
       struct cgraph_node *tgt = cgraph_get_node (node->thunk.alias);
+      struct cgraph_node *n;
+
+      for (n = tgt; n && n->alias;
+          n = n->analyzed ? cgraph_alias_aliased_node (n) : NULL)
+       if (n == node)
+         {
+           error ("function %q+D part of alias cycle", node->decl);
+           node->alias = false;
+           return;
+         }
       if (!VEC_length (ipa_ref_t, node->ref_list.references))
         ipa_record_reference (node, NULL, tgt, NULL, IPA_REF_ALIAS, NULL);
       if (node->same_body_alias)
index bad0b702bf112ccf65c454bedbbae068c2abf5e2..2e97e5b567097449bc9a529820fa8ea24576fdca 100644 (file)
@@ -1,3 +1,10 @@
+2012-02-02 Jan Hubicka  <jh@suse.cz>
+          Tom de Vries  <tom@codesourcery.com>
+
+       PR middle-end/51998
+       * testsuite/gcc.dg/alias-12.c: New testcase.
+       * testsuite/gcc.dg/alias-13.c: New testcase.
+
 2012-02-02  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/52086
diff --git a/gcc/testsuite/gcc.dg/alias-12.c b/gcc/testsuite/gcc.dg/alias-12.c
new file mode 100644 (file)
index 0000000..721716c
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-require-alias "" } */
+/* { dg-options "-O2" } */
+static void f (void) __attribute__((alias("f"))); // { dg-error "part of alias cycle" "" }
+
+void g ()
+{
+  f ();
+}
diff --git a/gcc/testsuite/gcc.dg/alias-13.c b/gcc/testsuite/gcc.dg/alias-13.c
new file mode 100644 (file)
index 0000000..a8390d4
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-require-alias "" } */
+/* { dg-options "-O2" } */
+static void f (void) __attribute__((alias("g"))); static void g (void) __attribute__((alias("f"))); // { dg-error "part of alias cycle" "" }
+
+void h ()
+{
+  f ();
+}
index e01accb21dc81c4663a7d3d27f3d4a64f39f96d7..c2d88c3bd761a897ef882c898acfc387238af05a 100644 (file)
@@ -477,6 +477,16 @@ varpool_analyze_pending_decls (void)
       if (node->alias && node->alias_of)
        {
          struct varpool_node *tgt = varpool_node (node->alias_of);
+          struct varpool_node *n;
+
+         for (n = tgt; n && n->alias;
+              n = n->analyzed ? varpool_alias_aliased_node (n) : NULL)
+           if (n == node)
+             {
+               error ("variable %q+D part of alias cycle", node->decl);
+               node->alias = false;
+               continue;
+             }
          if (!VEC_length (ipa_ref_t, node->ref_list.references))
            ipa_record_reference (NULL, node, NULL, tgt, IPA_REF_ALIAS, NULL);
          /* C++ FE sometimes change linkage flags after producing same body aliases.  */