re PR c/28287 (ICE with misplaced attribute weak)

gcc
	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.

From-SVN: r116170
This commit is contained in:
Danny Smith 2006-08-15 21:46:30 +00:00 committed by Danny Smith
parent c1782c0e69
commit 55af93a8a3
4 changed files with 39 additions and 2 deletions

View 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

View 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;
}

View 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

View 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" "" } */