public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r9-9418] varasm: Fix ICE with -fsyntax-only [PR99035]
@ 2021-04-20 23:32 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-04-20 23:32 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6496e9154309cbd911f944147da1246628e393da
commit r9-9418-g6496e9154309cbd911f944147da1246628e393da
Author: Jakub Jelinek <jakub@redhat.com>
Date: Wed Feb 10 19:52:37 2021 +0100
varasm: Fix ICE with -fsyntax-only [PR99035]
My FE change from 2 years ago uses TREE_ASM_WRITTEN in -fsyntax-only
mode more aggressively to avoid "expanding" functions multiple times.
With -fsyntax-only nothing is really expanded, so I think it is acceptable
to adjust the assert and allow declare_weak at any time, with -fsyntax-only
we know it is during parsing only anyway.
2021-02-10 Jakub Jelinek <jakub@redhat.com>
PR c++/99035
* varasm.c (declare_weak): For -fsyntax-only, allow even
TREE_ASM_WRITTEN function decls.
* g++.dg/ext/weak6.C: New test.
(cherry picked from commit a964f494cd5a90f631b8c0c01777a9899e0351ce)
Diff:
---
gcc/testsuite/g++.dg/ext/weak6.C | 8 ++++++++
gcc/varasm.c | 7 ++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/gcc/testsuite/g++.dg/ext/weak6.C b/gcc/testsuite/g++.dg/ext/weak6.C
new file mode 100644
index 00000000000..e9a70ee0dad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/weak6.C
@@ -0,0 +1,8 @@
+// PR c++/99035
+// { dg-do compile }
+// { dg-require-weak "" }
+// { dg-options "-fsyntax-only" }
+
+extern void * foo (void);
+void * foo (void) { return (void *)foo; }
+#pragma weak foo
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 8d87e28cc7c..7749be05b6f 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -5670,7 +5670,12 @@ merge_weak (tree newdecl, tree olddecl)
void
declare_weak (tree decl)
{
- gcc_assert (TREE_CODE (decl) != FUNCTION_DECL || !TREE_ASM_WRITTEN (decl));
+ /* With -fsyntax-only, TREE_ASM_WRITTEN might be set on certain function
+ decls earlier than normally, but as with -fsyntax-only nothing is really
+ emitted, there is no harm in marking it weak later. */
+ gcc_assert (TREE_CODE (decl) != FUNCTION_DECL
+ || !TREE_ASM_WRITTEN (decl)
+ || flag_syntax_only);
if (! TREE_PUBLIC (decl))
{
error ("weak declaration of %q+D must be public", decl);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-20 23:32 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-20 23:32 [gcc r9-9418] varasm: Fix ICE with -fsyntax-only [PR99035] Jakub Jelinek
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).