From: Nathan Sidwell Date: Wed, 1 Jun 2016 13:41:19 +0000 (+0000) Subject: nvptx.c (nvptx_assemble_undefined_decl): Reject undefined weak. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=721547cd0dd19a03a9e9405cfdbd6d0870eaaf68;p=gcc.git nvptx.c (nvptx_assemble_undefined_decl): Reject undefined weak. * 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8ab3fc62693..5d10b0eea08 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-06-01 Nathan Sidwell + + * config/nvptx/nvptx.c (nvptx_assemble_undefined_decl): Reject + undefined weak. + 2016-06-01 Richard Biener PR tree-optimization/71261 @@ -109,7 +114,8 @@ 2016-05-31 Oleg Endo * 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. diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c index 1bd18710245..6c78699d75f 100644 --- a/gcc/config/nvptx/nvptx.c +++ b/gcc/config/nvptx/nvptx.c @@ -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 "); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ba28ae8d6f4..b903f402834 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-06-01 Nathan Sidwell + + * c-c++-common/torture/pr57945.c: Add expected PTX error. + * gcc.target/nvptx/weak.c: New. + 2016-06-01 Richard Biener PR tree-optimization/71261 diff --git a/gcc/testsuite/c-c++-common/torture/pr57945.c b/gcc/testsuite/c-c++-common/torture/pr57945.c index 0803e8ff21f..5a5977f31df 100644 --- a/gcc/testsuite/c-c++-common/torture/pr57945.c +++ b/gcc/testsuite/c-c++-common/torture/pr57945.c @@ -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 index 00000000000..a756b95c3c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/nvptx/weak.c @@ -0,0 +1,9 @@ + +extern int __attribute__((weak)) decl; /* { dg-error "weak declarations" } */ +int __attribute__((weak)) defn; + +int Foo () +{ + return decl + defn; +} +