nvptx.c (nvptx_assemble_undefined_decl): Reject undefined weak.
authorNathan Sidwell <nathan@gcc.gnu.org>
Wed, 1 Jun 2016 13:41:19 +0000 (13:41 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Wed, 1 Jun 2016 13:41:19 +0000 (13:41 +0000)
* config/nvptx/nvptx.c (nvptx_assemble_undefined_decl): Reject
undefined weak.

testsuite/
* c-c++-common/torture/pr57945.c: Add expected PTX error.
* gcc.target/nvptx/weak.c: New.

From-SVN: r236990

gcc/ChangeLog
gcc/config/nvptx/nvptx.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/torture/pr57945.c
gcc/testsuite/gcc.target/nvptx/weak.c [new file with mode: 0644]

index 8ab3fc62693a5951fad72bb3c7827bdc37c87d97..5d10b0eea084a85246bb7e6d1542acab46570562 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-01  Nathan Sidwell  <nathan@acm.org>
+
+       * config/nvptx/nvptx.c (nvptx_assemble_undefined_decl): Reject
+       undefined weak.
+
 2016-06-01  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71261
 2016-05-31  Oleg Endo  <olegendo@gcc.gnu.org>
 
        * config/sh/constraints.md (b): Remove constraint.
-       * config/sh/predicates.md (arith_reg_operand): Remove TARGET_REGISTER_P.
+       * config/sh/predicates.md (arith_reg_operand): Remove
+       TARGET_REGISTER_P.
        * config/sh/sh-modes.def (PDI): Remove.
        * config/sh/sh.c (sh_target_reg_class,
        sh_optimize_target_register_callee_saved): Remove functions.
index 1bd1871024519744c07a66de27379bcfbeb1b8bf..6c78699d75f6bdae0dc25bd6452352a8eb065bfc 100644 (file)
@@ -1777,6 +1777,12 @@ nvptx_assemble_undefined_decl (FILE *file, const char *name, const_tree decl)
   if (DECL_IN_CONSTANT_POOL (decl))
     return;
 
+  /*  We support weak defintions, and hence have the right
+      ASM_WEAKEN_DECL definition.  Diagnose the problem here.  */
+  if (DECL_WEAK (decl))
+    error_at (DECL_SOURCE_LOCATION (decl),
+             "PTX does not support weak declarations"
+             " (only weak definitions)");
   write_var_marker (file, false, TREE_PUBLIC (decl), name);
 
   fprintf (file, "\t.extern ");
index ba28ae8d6f4698d55e2dddf8e2f61e1ba22039cd..b903f402834c6c98bd36e1a231c1a41b43098f9e 100644 (file)
@@ -1,3 +1,8 @@
+2016-06-01  Nathan Sidwell  <nathan@acm.org>
+
+       * c-c++-common/torture/pr57945.c: Add expected PTX error.
+       * gcc.target/nvptx/weak.c: New.
+
 2016-06-01  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/71261
index 0803e8ff21f9639dc5e07e6826918a217b7ea50c..5a5977f31df2f5e46b37b7630e2cda2d71f385b9 100644 (file)
@@ -9,3 +9,5 @@ foo (void)
 {
   return &i ? i : 0;
 }
+
+/* { dg-error "PTX does not support weak declarations" "" { target nvptx-*-* } 5 } */
diff --git a/gcc/testsuite/gcc.target/nvptx/weak.c b/gcc/testsuite/gcc.target/nvptx/weak.c
new file mode 100644 (file)
index 0000000..a756b95
--- /dev/null
@@ -0,0 +1,9 @@
+
+extern int __attribute__((weak)) decl;  /* { dg-error "weak declarations" } */
+int __attribute__((weak)) defn;
+
+int Foo ()
+{
+  return decl + defn;
+}
+