From: Marek Polacek Date: Tue, 25 Aug 2015 20:28:59 +0000 (+0000) Subject: re PR middle-end/67330 (ICE handling weak attributes) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c316b5e4f1f7987e37641667fb47eb37f32f0e2b;p=gcc.git re PR middle-end/67330 (ICE handling weak attributes) PR middle-end/67330 * varasm.c (declare_weak): Return after giving an error. * c-common.c (handle_weak_attribute): Don't check whether the visibility can be changed here. * gcc.dg/weak/weak-18.c: New test. From-SVN: r227190 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c79fb4870f7..fd4ade37af3 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-08-25 Marek Polacek + + PR middle-end/67330 + * varasm.c (declare_weak): Return after giving an error. + 2015-08-25 David Malcolm * gcc-main.c (main): Add params to driver ctor. diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 2a5758aac59..8b4009e85fd 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,9 @@ +2015-08-25 Marek Polacek + + PR middle-end/67330 + * c-common.c (handle_weak_attribute): Don't check whether the + visibility can be changed here. + 2015-08-22 Manuel López-Ibáñez * c-lex.c (c_lex_with_flags): Use explicit locations. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index ff502e56dbb..7691035c7f8 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -8328,12 +8328,7 @@ handle_weak_attribute (tree *node, tree name, return NULL_TREE; } else if (VAR_OR_FUNCTION_DECL_P (*node)) - { - struct symtab_node *n = symtab_node::get (*node); - if (n && n->refuse_visibility_changes) - error ("%+D declared weak after being used", *node); - declare_weak (*node); - } + declare_weak (*node); else warning (OPT_Wattributes, "%qE attribute ignored", name); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7deb14776ca..e8365be37f0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-08-25 Marek Polacek + + PR middle-end/67330 + * gcc.dg/weak/weak-18.c: New test. + 2015-08-25 David Malcolm * jit.dg/test-error-pr63969-missing-driver.c: Add call to diff --git a/gcc/testsuite/gcc.dg/weak/weak-18.c b/gcc/testsuite/gcc.dg/weak/weak-18.c new file mode 100644 index 00000000000..ebeb4d5ba8a --- /dev/null +++ b/gcc/testsuite/gcc.dg/weak/weak-18.c @@ -0,0 +1,9 @@ +/* PR middle-end/67330 */ +/* { dg-do compile } */ +/* { dg-require-weak "" } */ + +void +f (void) +{ + __attribute__ ((weak)) int a; /* { dg-error "weak declaration of .a. must be public" } */ +} diff --git a/gcc/varasm.c b/gcc/varasm.c index 7fa2e7be8e4..d9290a17cbb 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -5403,7 +5403,10 @@ declare_weak (tree decl) { gcc_assert (TREE_CODE (decl) != FUNCTION_DECL || !TREE_ASM_WRITTEN (decl)); if (! TREE_PUBLIC (decl)) - error ("weak declaration of %q+D must be public", decl); + { + error ("weak declaration of %q+D must be public", decl); + return; + } else if (!TARGET_SUPPORTS_WEAK) warning (0, "weak declaration of %q+D not supported", decl);