This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/35330] [4.8/4.9/5 regression] ICE with invalid pragma weak
- From: "ktietz at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 26 Feb 2015 17:22:48 +0000
- Subject: [Bug c/35330] [4.8/4.9/5 regression] ICE with invalid pragma weak
- Auto-submitted: auto-generated
- References: <bug-35330-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35330
--- Comment #12 from Kai Tietz <ktietz at gcc dot gnu.org> ---
issue seems to be that in declare_weak we don't check that DECL is actually
either a function, or a variable declaration.
Fix would be to add an error-message in declare_weak ().
Index: varasm.c
===================================================================
@@ -5398,6 +5399,12 @@ void
declare_weak (tree decl)
{
gcc_assert (TREE_CODE (decl) != FUNCTION_DECL || !TREE_ASM_WRITTEN (decl));
+ if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL)
+ {
+ error ("weak declaration of %q+D has to be either a function,"
+ " or a variable declaration", decl);
+ return;
+ }
if (! TREE_PUBLIC (decl))
error ("weak declaration of %q+D must be public", decl);
else if (!TARGET_SUPPORTS_WEAK)