diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-02-07 00:32:37 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-02-07 00:32:37 +0000 |
commit | 9e830260e94660768c1afb379b85c1d941771589 (patch) | |
tree | 565bd86f7c66276a4fe50b4ebe612007ef76459a | |
parent | fdd3cb8737c2b5b867c705eb5cb61605c80d9de2 (diff) | |
download | gcc-9e830260e94660768c1afb379b85c1d941771589.tar.gz |
PR c/35434
* c-common.c (handle_alias_attribute): Disallow attribute for
anything not a FUNCTION_DECL or VAR_DECL.
testsuite:
* gcc.dg/attr-alias-4.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@143998 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-common.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/attr-alias-4.c | 4 |
4 files changed, 21 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1e450105874..8befe01fa8c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2009-02-06 Joseph Myers <joseph@codesourcery.com> + + PR c/35434 + * c-common.c (handle_alias_attribute): Disallow attribute for + anything not a FUNCTION_DECL or VAR_DECL. + 2009-02-06 Janis Johnson <janis187@us.ibm.com> PR c/39035 diff --git a/gcc/c-common.c b/gcc/c-common.c index dbc9676b099..e7b90674d50 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -6015,7 +6015,12 @@ handle_alias_attribute (tree *node, tree name, tree args, { tree decl = *node; - if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl)) + if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) + { + warning (OPT_Wattributes, "%qE attribute ignored", name); + *no_add_attrs = true; + } + else if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl)) || (TREE_CODE (decl) != FUNCTION_DECL && TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl)) /* A static variable declaration is always a tentative definition, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index bf0aca756ee..77e3ff7bd22 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2009-02-06 Joseph Myers <joseph@codesourcery.com> + + PR c/35434 + * gcc.dg/attr-alias-4.c: New test. + 2009-02-06 Janis Johnson <janis187@us.ibm.com> PR c/39035 diff --git a/gcc/testsuite/gcc.dg/attr-alias-4.c b/gcc/testsuite/gcc.dg/attr-alias-4.c new file mode 100644 index 00000000000..fb15a20bf84 --- /dev/null +++ b/gcc/testsuite/gcc.dg/attr-alias-4.c @@ -0,0 +1,4 @@ +/* ICE on invalid alias attribute: PR 35434. */ +/* { dg-do compile } */ +/* { dg-options "" } */ +typedef int i __attribute__((alias("j"))); /* { dg-warning "ignored" } */ |