This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] Fix tree check ICE in PR c/28287
- From: Danny Smith <dannysmith at clear dot net dot nz>
- To: GCC-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 15 Aug 2006 11:24:52 +1200
- Subject: [Patch] Fix tree check ICE in PR c/28287
:ADDPATCH c:
Here is a proposed patch for PR 28287, which is a tree check ICE
following the application of weak attribute to a PARM_DECL.
The patch simply ignores the attribute and warns if not a FUNCTION_
or VAR_DECL. This makes it consistent with maybe_apply_pragma_weak in
c-pragma.c, which already ignores.
Tested on i686-pc-mingw32 (which supports weak)
gcc version 4.2.0 20060813 (experimental) bootstrap
2006-08-15 Danny Smith <dannysmith@users.sourceforge.net>
PR 28287 c:
* c-common.c (handle_weak_attribute): Ignore and warn if
not a FUNCTION_ or VAR_DECL
testsuite/ChangeLog
* gcc.dg/attr-invalid.c: Add tests for invalid weak attribute.
Index: c-common.c
===================================================================
*** c-common.c (revision 116116)
--- c-common.c (working copy)
*************** handle_aligned_attribute (tree *node, tr
*** 4737,4748 ****
struct attribute_spec.handler. */
static tree
! handle_weak_attribute (tree *node, tree ARG_UNUSED (name),
tree ARG_UNUSED (args),
int ARG_UNUSED (flags),
bool * ARG_UNUSED (no_add_attrs))
{
! declare_weak (*node);
return NULL_TREE;
}
--- 4737,4753 ----
struct attribute_spec.handler. */
static tree
! handle_weak_attribute (tree *node, tree name,
tree ARG_UNUSED (args),
int ARG_UNUSED (flags),
bool * ARG_UNUSED (no_add_attrs))
{
! 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: testsuite/gcc.dg/attr-invalid.c
===================================================================
*** testsuite/gcc.dg/attr-invalid.c (revision 116116)
--- testsuite/gcc.dg/attr-invalid.c (working copy)
*************** int ATSYM(fn_vars) (void) {
*** 56,58 ****
--- 56,80 ----
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" "" } */
+