re PR c/35330 (ICE with invalid pragma weak)
authorKai Tietz <ktietz@redhat.com>
Fri, 27 Feb 2015 10:44:43 +0000 (11:44 +0100)
committerKai Tietz <ktietz@gcc.gnu.org>
Fri, 27 Feb 2015 10:44:43 +0000 (11:44 +0100)
2015-02-27  Kai Tietz  <ktietz@redhat.com>

PR c/35330
* c-pragma.c (handle_pragma_weak): Do not try to create
weak/alias of declarations not being function, or variable
declarations.

2015-02-27  Kai Tietz  <ktietz@redhat.com>

PR c/35330
* gcc.dg/weak/weak-17.c: New file.

From-SVN: r221053

gcc/c-family/ChangeLog
gcc/c-family/c-pragma.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/weak/weak-17.c [new file with mode: 0644]

index ffa01c6337c5502df82efcaa514964686cc2eac6..ca5a412fad920919b4f78dab1f419f0e56b6fe39 100644 (file)
@@ -1,3 +1,10 @@
+2015-02-27  Kai Tietz  <ktietz@redhat.com>
+
+       PR c/35330
+       * c-pragma.c (handle_pragma_weak): Do not try to create
+       weak/alias of declarations not being function, or variable
+       declarations.
+
 2015-02-24  Thomas Schwinge  <thomas@codesourcery.com>
 
        PR libgomp/64625
index 718a310cf50158b3daf9ea9bc0defd43200339c5..6894f0e7c3d1ea932ff05f370680be3d18dfcf94 100644 (file)
@@ -392,6 +392,9 @@ handle_pragma_weak (cpp_reader * ARG_UNUSED (dummy))
   decl = identifier_global_value (name);
   if (decl && DECL_P (decl))
     {
+      if (!VAR_OR_FUNCTION_DECL_P (decl))
+       GCC_BAD2 ("%<#pragma weak%> declaration of %q+D not allowed,"
+                 " ignored", decl);
       apply_pragma_weak (decl, value);
       if (value)
        {
index 3200f413e6c0c2f06ab67136303f3653ba1bf72b..5ca86b107f89e8d8a651690437cb763785e14e20 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-27  Kai Tietz  <ktietz@redhat.com>
+
+       PR c/35330
+       * gcc.dg/weak/weak-17.c: New file.
+
 2015-02-27  Richard Biener  <rguenther@suse.de>
 
        PR lto/65193
diff --git a/gcc/testsuite/gcc.dg/weak/weak-17.c b/gcc/testsuite/gcc.dg/weak/weak-17.c
new file mode 100644 (file)
index 0000000..b4bda9b
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-require-weak "" } */
+#pragma weak int = foo
+
+/* { dg-warning "declaration of" "weak" { target *-*-* } 0 } */