diff options
author | Martin Sebor <msebor@redhat.com> | 2020-03-18 14:47:29 -0600 |
---|---|---|
committer | Martin Sebor <msebor@redhat.com> | 2020-03-18 14:47:29 -0600 |
commit | 3512dc0108afbed3bece2e9fa1719fb3ce1d73d9 (patch) | |
tree | cda4737627e690c9602d88bf15d77ade17d4b108 /gcc/cgraphunit.c | |
parent | 7a5fffa5ed0a8edfca772d43465d2c9b55bb23cc (diff) | |
download | gcc-3512dc0108afbed3bece2e9fa1719fb3ce1d73d9.zip gcc-3512dc0108afbed3bece2e9fa1719fb3ce1d73d9.tar.gz gcc-3512dc0108afbed3bece2e9fa1719fb3ce1d73d9.tar.bz2 |
PR ipa/92799 - ICE on a weakref function definition followed by a declaration
gcc/testsuite/ChangeLog:
PR ipa/92799
* gcc.dg/attr-weakref-5.c: New test.
gcc/ChangeLog:
PR ipa/92799
* cgraphunit.c (process_function_and_variable_attributes): Also
complain about weakref function definitions and drop all effects
of the attribute.
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r-- | gcc/cgraphunit.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index a9dd288..fd58636 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -861,14 +861,23 @@ process_function_and_variable_attributes (cgraph_node *first, " attribute have effect only on public objects"); } if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)) - && (node->definition && !node->alias)) + && node->definition + && (!node->alias || DECL_INITIAL (decl) != error_mark_node)) { - warning_at (DECL_SOURCE_LOCATION (node->decl), OPT_Wattributes, + /* NODE->DEFINITION && NODE->ALIAS is nonzero for valid weakref + function declarations; DECL_INITIAL is non-null for invalid + weakref functions that are also defined. */ + warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wattributes, "%<weakref%> attribute ignored" " because function is defined"); DECL_WEAK (decl) = 0; DECL_ATTRIBUTES (decl) = remove_attribute ("weakref", DECL_ATTRIBUTES (decl)); + DECL_ATTRIBUTES (decl) = remove_attribute ("alias", + DECL_ATTRIBUTES (decl)); + node->alias = false; + node->weakref = false; + node->transparent_alias = false; } else if (lookup_attribute ("alias", DECL_ATTRIBUTES (decl)) && node->definition |