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
This commit is contained in:
Marek Polacek 2015-08-25 20:28:59 +00:00 committed by Marek Polacek
parent 630a286ab6
commit c316b5e4f1
6 changed files with 30 additions and 7 deletions

View File

@ -1,3 +1,8 @@
2015-08-25 Marek Polacek <polacek@redhat.com>
PR middle-end/67330
* varasm.c (declare_weak): Return after giving an error.
2015-08-25 David Malcolm <dmalcolm@redhat.com>
* gcc-main.c (main): Add params to driver ctor.

View File

@ -1,3 +1,9 @@
2015-08-25 Marek Polacek <polacek@redhat.com>
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 <manu@gcc.gnu.org>
* c-lex.c (c_lex_with_flags): Use explicit locations.

View File

@ -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);

View File

@ -1,3 +1,8 @@
2015-08-25 Marek Polacek <polacek@redhat.com>
PR middle-end/67330
* gcc.dg/weak/weak-18.c: New test.
2015-08-25 David Malcolm <dmalcolm@redhat.com>
* jit.dg/test-error-pr63969-missing-driver.c: Add call to

View File

@ -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" } */
}

View File

@ -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);