This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/35330] [4.8/4.9/5 regression] ICE with invalid pragma weak


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]