public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] PR ipa/92799 - ICE on a weakref function definition followed by a declaration
@ 2020-03-30 10:57 Martin Liska
0 siblings, 0 replies; only message in thread
From: Martin Liska @ 2020-03-30 10:57 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:3512dc0108afbed3bece2e9fa1719fb3ce1d73d9
commit 3512dc0108afbed3bece2e9fa1719fb3ce1d73d9
Author: Martin Sebor <msebor@redhat.com>
Date: Wed Mar 18 14:47:29 2020 -0600
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.
Diff:
---
gcc/ChangeLog | 7 +++++++
gcc/cgraphunit.c | 13 +++++++++++--
gcc/testsuite/ChangeLog | 5 +++++
gcc/testsuite/gcc.dg/attr-weakref-5.c | 31 +++++++++++++++++++++++++++++++
4 files changed, 54 insertions(+), 2 deletions(-)
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0f7df20db71..8694f272a9c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2020-03-18 Martin Sebor <msebor@redhat.com>
+
+ PR ipa/92799
+ * cgraphunit.c (process_function_and_variable_attributes): Also
+ complain about weakref function definitions and drop all effects
+ of the attribute.
+
2020-03-18 Andre Vieira <andre.simoesdiasvieira@arm.com>
Mihail Ionescu <mihail.ionescu@arm.com>
Srinath Parvathaneni <srinath.parvathaneni@arm.com>
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index a9dd288be57..fd586366bb9 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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8fee29fad0d..9e5fecd24f7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-18 Martin Sebor <msebor@redhat.com>
+
+ PR ipa/92799
+ * gcc.dg/attr-weakref-5.c: New test.
+
2020-03-18 Andre Vieira <andre.simoesdiasvieira@arm.com>
Mihail Ionescu <mihail.ionescu@arm.com>
Srinath Parvathaneni <srinath.parvathaneni@arm.com>
diff --git a/gcc/testsuite/gcc.dg/attr-weakref-5.c b/gcc/testsuite/gcc.dg/attr-weakref-5.c
new file mode 100644
index 00000000000..e2f04068230
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/attr-weakref-5.c
@@ -0,0 +1,31 @@
+/* PR middle-end/92799 - ICE on a weakref function definition followed
+ by a declaration
+ { dg-do compile }
+ { dg-options "-Wall" } */
+
+static __attribute__ ((weakref ("bar"))) void f0 (void) { } // { dg-warning "'weakref' attribute ignored because function is defined" }
+
+extern void f0 (void);
+
+void* use_f0 (void) { return f0; }
+
+
+static __attribute__ ((weakref ("bar"))) void f1 (void) { } // { dg-warning "'weakref' attribute ignored because function is defined" }
+
+static void f1 (void);
+
+void* use_f1 (void) { return f1; }
+
+
+static __attribute__ ((weakref ("bar"))) void f2 (void);
+
+static void f2 (void) { } // { dg-error "redefinition" }
+
+void* use_f2 (void) { return f2; }
+
+
+static __attribute__ ((weakref ("bar"))) void f3 (void);
+
+void f3 (void) { } // { dg-error "redefinition" }
+
+void* use_f3 (void) { return f3; }
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-03-30 10:57 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 10:57 [gcc(refs/users/marxin/heads/marxin-gcc-benchmark-branch)] PR ipa/92799 - ICE on a weakref function definition followed by a declaration Martin Liska
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).