2016-06-01 Nathan Sidwell <nathan@acm.org>
* 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.
===================================================================
@@ -1777,6 +1777,12 @@ nvptx_assemble_undefined_decl (FILE *fil
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 ");
===================================================================
@@ -9,3 +9,5 @@ foo (void)
{
return &i ? i : 0;
}
+
+/* { dg-error "PTX does not support weak declarations" "" { target nvptx-*-* } 5 } */
===================================================================
@@ -0,0 +1,9 @@
+
+extern int __attribute__((weak)) decl; /* { dg-error "weak declarations" } */
+int __attribute__((weak)) defn;
+
+int Foo ()
+{
+ return decl + defn;
+}
+