OSDN Git Service

gcc
authordannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Aug 2006 21:46:30 +0000 (21:46 +0000)
committerdannysmith <dannysmith@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 15 Aug 2006 21:46:30 +0000 (21:46 +0000)
PR c/28287
* c-common.c (handle_weak_attribute): Ignore and warn if
not a FUNCTION_ or VAR_DECL

testsuite

* gcc.dg/attr-invalid.c: Add tests for invalid weak attribute.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116170 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/c-common.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/attr-invalid.c

index 218be97..0658f36 100644 (file)
@@ -1,3 +1,9 @@
+2006-08-15  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       PR c/28287
+       * c-common.c (handle_weak_attribute): Ignore and warn if
+       not a FUNCTION_ or VAR_DECL.
+
 2006-07-15  Mike Stump  <mrs@apple.com>
 
        PR c/28280
index 58c48d8..167d04b 100644 (file)
@@ -4737,12 +4737,17 @@ handle_aligned_attribute (tree *node, tree ARG_UNUSED (name), tree args,
    struct attribute_spec.handler.  */
 
 static tree
-handle_weak_attribute (tree *node, tree ARG_UNUSED (name),
+handle_weak_attribute (tree *node, tree name,
                       tree ARG_UNUSED (args),
                       int ARG_UNUSED (flags),
                       bool * ARG_UNUSED (no_add_attrs))
 {
-  declare_weak (*node);
+  if (TREE_CODE (*node) == FUNCTION_DECL
+      || TREE_CODE (*node) == VAR_DECL)
+    declare_weak (*node);
+  else
+    warning (OPT_Wattributes, "%qE attribute ignored", name);
+       
 
   return NULL_TREE;
 }
index 030212f..acf6d70 100644 (file)
@@ -1,3 +1,8 @@
+2006-08-15  Danny Smith  <dannysmith@users.sourceforge.net>
+
+       PR c/28287
+       * gcc.dg/attr-invalid.c: Add tests for invalid weak attribute.
+
 2006-08-15  Lee Millward  <lee.millward@codesourcery.com>
 
        PR c++/28594
index 9cb6454..c6c437d 100644 (file)
@@ -56,3 +56,24 @@ int ATSYM(fn_vars) (void) {
   auto int lvar ATTR; /* { dg-warning "attribute ignored" "" } */
   return 0;
 }
+
+
+/* PR 28287 */
+/* These are invalid on all targets.  Applying to PARM_ or FIELD_DECL
+   also caused a tree checking ice on targets that support weak,  */
+#undef AT
+#define AT weak
+
+typedef int ATSYM(type) ATTR; /* { dg-warning "attribute ignored" "" } */
+
+typedef int (*ATSYM(fntype))(void) ATTR; /* { dg-warning "attribute ignored" "" } */
+
+struct ATSYM(struct) {
+  char dummy ATTR; /* { dg-warning "attribute ignored" "" } */
+};
+
+int ATSYM(fn_knrarg) (arg)
+  int arg ATTR; /* { dg-warning "attribute ignored" "" } */
+{ return 0; }
+
+int ATSYM(fn_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute ignored" "" } */