diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-19 02:07:06 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-02-19 02:07:06 +0000 |
commit | d0a31bd870118dd2ab77285a2a0e4086b3bf4f67 (patch) | |
tree | 61bfc9f2c849a8b517a22fb036bb9ba1c8838f72 /gcc | |
parent | e22a6b11f360c5eb79d68da905318944a9c63dcf (diff) | |
download | gcc-d0a31bd870118dd2ab77285a2a0e4086b3bf4f67.tar.gz |
* c-common.c (handle_used_attribute): Accept static data too.
* gcc.dg/attr-invalid.c: Allow __used__ on static data.
* gcc.dg/attr-used-2.c: New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63082 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/c-common.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/attr-invalid.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/attr-used-2.c | 11 |
5 files changed, 31 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cc6839a6fcf..04b7f814bd4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,8 @@ -003-02-18 Nick Clifton <nickc@redhat.com> +2003-02-18 Richard Henderson <rth@redhat.com> + + * c-common.c (handle_used_attribute): Accept static data too. + +2003-02-18 Nick Clifton <nickc@redhat.com> Aldy Hernandez <aldyh@redhat.com> * testsuite/gcc.dg/20030218-1.c: New. diff --git a/gcc/c-common.c b/gcc/c-common.c index c78692fd959..b49dc25f43d 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5415,16 +5415,19 @@ handle_always_inline_attribute (node, name, args, flags, no_add_attrs) struct attribute_spec.handler. */ static tree -handle_used_attribute (node, name, args, flags, no_add_attrs) - tree *node; +handle_used_attribute (pnode, name, args, flags, no_add_attrs) + tree *pnode; tree name; tree args ATTRIBUTE_UNUSED; int flags ATTRIBUTE_UNUSED; bool *no_add_attrs; { - if (TREE_CODE (*node) == FUNCTION_DECL) - TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (*node)) - = TREE_USED (*node) = 1; + tree node = *pnode; + + if (TREE_CODE (node) == FUNCTION_DECL + || (TREE_CODE (node) == VAR_DECL && TREE_STATIC (node))) + TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (node)) + = TREE_USED (node) = 1; else { warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 220c69643e4..4c7b8b38e1c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-02-18 Richard Henderson <rth@redhat.com> + + * gcc.dg/attr-invalid.c: Allow __used__ on static data. + * gcc.dg/attr-used-2.c: New. + 2003-02-18 Mark Mitchell <mark@codesourcery.com> PR c++/9704 diff --git a/gcc/testsuite/gcc.dg/attr-invalid.c b/gcc/testsuite/gcc.dg/attr-invalid.c index a999c267c3a..9cb64541548 100644 --- a/gcc/testsuite/gcc.dg/attr-invalid.c +++ b/gcc/testsuite/gcc.dg/attr-invalid.c @@ -43,7 +43,7 @@ struct ATSYM(struct) { char dummy ATTR; /* { dg-warning "attribute ignored" "" } */ } ATTR; /* { dg-warning "does not apply to types" "" } */ -int ATSYM(var) ATTR; /* { dg-warning "attribute ignored" "" } */ +int ATSYM(var) ATTR; int ATSYM(fn_knrarg) (arg) int arg ATTR; /* { dg-warning "attribute ignored" "" } */ @@ -52,7 +52,7 @@ int ATSYM(fn_knrarg) (arg) int ATSYM(fn_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute ignored" "" } */ int ATSYM(fn_vars) (void) { - static int svar ATTR; /* { dg-warning "attribute ignored" "" } */ + static int svar ATTR; auto int lvar ATTR; /* { dg-warning "attribute ignored" "" } */ return 0; } diff --git a/gcc/testsuite/gcc.dg/attr-used-2.c b/gcc/testsuite/gcc.dg/attr-used-2.c new file mode 100644 index 00000000000..f78b94b53a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/attr-used-2.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-Wall -O2" } */ + +static int xyzzy __attribute__((__used__)) = 1; + +void foo() +{ + int x __attribute__((__used__)); /* { dg-warning "attribute ignored|unused variable" } */ +} + +/* { dg-final { scan-assembler "xyzzy" } } */ |