diff options
author | Danny Smith <dannysmith@users.sourceforge.net> | 2006-08-15 21:46:30 +0000 |
---|---|---|
committer | Danny Smith <dannysmith@gcc.gnu.org> | 2006-08-15 21:46:30 +0000 |
commit | 55af93a8a3f04d7a1953fafba7d7e169754cb863 (patch) | |
tree | 211877abcbf327a83cb6b5734399fa9e50c8c349 /gcc | |
parent | c1782c0e69d219d3ccceeca553a3d1d90622d1af (diff) | |
download | gcc-55af93a8a3f04d7a1953fafba7d7e169754cb863.zip gcc-55af93a8a3f04d7a1953fafba7d7e169754cb863.tar.gz gcc-55af93a8a3f04d7a1953fafba7d7e169754cb863.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-common.c | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/attr-invalid.c | 21 |
4 files changed, 39 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 218be97..0658f36 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/c-common.c b/gcc/c-common.c index 58c48d8..167d04b 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 030212f..acf6d70 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/gcc.dg/attr-invalid.c b/gcc/testsuite/gcc.dg/attr-invalid.c index 9cb6454..c6c437d 100644 --- a/gcc/testsuite/gcc.dg/attr-invalid.c +++ b/gcc/testsuite/gcc.dg/attr-invalid.c @@ -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" "" } */ |