re PR middle-end/36282 (Spurious warning "asm declaration ignored due to conflict...
authorJakub Jelinek <jakub@redhat.com>
Thu, 13 Mar 2014 20:56:06 +0000 (21:56 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 13 Mar 2014 20:56:06 +0000 (21:56 +0100)
PR middle-end/36282
* c-pragma.c (apply_pragma_weak): Only look at
TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) if
DECL_ASSEMBLER_NAME_SET_P (decl).
(maybe_apply_pending_pragma_weaks): Exit early if
vec_safe_is_empty (pending_weaks) rather than only when
!pending_weaks.
(maybe_apply_pragma_weak): Likewise.  If !DECL_ASSEMBLER_NAME_SET_P,
set assembler name back to NULL afterwards.

* c-c++-common/pr36282-1.c: New test.
* c-c++-common/pr36282-2.c: New test.
* c-c++-common/pr36282-3.c: New test.
* c-c++-common/pr36282-4.c: New test.

From-SVN: r208557

gcc/c-family/ChangeLog
gcc/c-family/c-pragma.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr36282-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr36282-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr36282-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/pr36282-4.c [new file with mode: 0644]

index e149e60..4e5aea4 100644 (file)
@@ -1,3 +1,15 @@
+2014-03-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/36282
+       * c-pragma.c (apply_pragma_weak): Only look at
+       TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)) if
+       DECL_ASSEMBLER_NAME_SET_P (decl).
+       (maybe_apply_pending_pragma_weaks): Exit early if
+       vec_safe_is_empty (pending_weaks) rather than only when
+       !pending_weaks.
+       (maybe_apply_pragma_weak): Likewise.  If !DECL_ASSEMBLER_NAME_SET_P,
+       set assembler name back to NULL afterwards.
+
 2014-03-11  Jason Merrill  <jason@redhat.com>
 
        * c.opt: Add -std=gnu++14.
index 2594d73..9e2a00e 100644 (file)
@@ -263,6 +263,7 @@ apply_pragma_weak (tree decl, tree value)
 
   if (SUPPORTS_WEAK && DECL_EXTERNAL (decl) && TREE_USED (decl)
       && !DECL_WEAK (decl) /* Don't complain about a redundant #pragma.  */
+      && DECL_ASSEMBLER_NAME_SET_P (decl)
       && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
     warning (OPT_Wpragmas, "applying #pragma weak %q+D after first use "
             "results in unspecified behavior", decl);
@@ -280,7 +281,7 @@ maybe_apply_pragma_weak (tree decl)
   /* Avoid asking for DECL_ASSEMBLER_NAME when it's not needed.  */
 
   /* No weak symbols pending, take the short-cut.  */
-  if (!pending_weaks)
+  if (vec_safe_is_empty (pending_weaks))
     return;
   /* If it's not visible outside this file, it doesn't matter whether
      it's weak.  */
@@ -292,7 +293,13 @@ maybe_apply_pragma_weak (tree decl)
   if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL)
     return;
 
-  id = DECL_ASSEMBLER_NAME (decl);
+  if (DECL_ASSEMBLER_NAME_SET_P (decl))
+    id = DECL_ASSEMBLER_NAME (decl);
+  else
+    {
+      id = DECL_ASSEMBLER_NAME (decl);
+      SET_DECL_ASSEMBLER_NAME (decl, NULL_TREE);
+    }
 
   FOR_EACH_VEC_ELT (*pending_weaks, i, pe)
     if (id == pe->name)
@@ -313,7 +320,7 @@ maybe_apply_pending_pragma_weaks (void)
   pending_weak *pe;
   symtab_node *target;
 
-  if (!pending_weaks)
+  if (vec_safe_is_empty (pending_weaks))
     return;
 
   FOR_EACH_VEC_ELT (*pending_weaks, i, pe)
index d5f33a7..3df9dbb 100644 (file)
@@ -1,3 +1,11 @@
+2014-03-13  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/36282
+       * c-c++-common/pr36282-1.c: New test.
+       * c-c++-common/pr36282-2.c: New test.
+       * c-c++-common/pr36282-3.c: New test.
+       * c-c++-common/pr36282-4.c: New test.
+
 2014-03-13  Richard Henderson  <rth@redhat.com>
 
        PR debug/60438
diff --git a/gcc/testsuite/c-c++-common/pr36282-1.c b/gcc/testsuite/c-c++-common/pr36282-1.c
new file mode 100644 (file)
index 0000000..abe11e7
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR middle-end/36282 */
+/* { dg-do compile } */
+
+#pragma weak bar
+
+extern void *baz (void *dest, const void *src, __SIZE_TYPE__ n);
+extern __typeof (baz) baz __asm("bazfn"); /* { dg-bogus "asm declaration ignored due to conflict with previous rename" } */
+
+void
+foo (void)
+{
+}
diff --git a/gcc/testsuite/c-c++-common/pr36282-2.c b/gcc/testsuite/c-c++-common/pr36282-2.c
new file mode 100644 (file)
index 0000000..86d3ad6
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR middle-end/36282 */
+/* { dg-do compile } */
+
+extern void *baz (void *dest, const void *src, __SIZE_TYPE__ n);
+extern __typeof (baz) baz __asm("bazfn"); /* { dg-bogus "asm declaration ignored due to conflict with previous rename" } */
+
+void
+foo (void)
+{
+}
diff --git a/gcc/testsuite/c-c++-common/pr36282-3.c b/gcc/testsuite/c-c++-common/pr36282-3.c
new file mode 100644 (file)
index 0000000..8982470
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR middle-end/36282 */
+/* { dg-do compile } */
+
+void bar (void);
+#pragma weak bar
+
+extern void *baz (void *dest, const void *src, __SIZE_TYPE__ n);
+extern __typeof (baz) baz __asm("bazfn"); /* { dg-bogus "asm declaration ignored due to conflict with previous rename" } */
+
+void
+foo (void)
+{
+}
diff --git a/gcc/testsuite/c-c++-common/pr36282-4.c b/gcc/testsuite/c-c++-common/pr36282-4.c
new file mode 100644 (file)
index 0000000..f6f40f8
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR middle-end/36282 */
+/* { dg-do compile } */
+
+#pragma weak bar
+void bar (void);
+
+extern void *baz (void *dest, const void *src, __SIZE_TYPE__ n);
+extern __typeof (baz) baz __asm("bazfn"); /* { dg-bogus "asm declaration ignored due to conflict with previous rename" } */
+
+void
+foo (void)
+{
+}