Commit d7ddbe24 by Richard Henderson

c-common.c (handle_used_attribute): Accept static data too.

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

From-SVN: r63082
parent 05e9e0a5
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> Aldy Hernandez <aldyh@redhat.com>
* testsuite/gcc.dg/20030218-1.c: New. * testsuite/gcc.dg/20030218-1.c: New.
......
...@@ -5415,16 +5415,19 @@ handle_always_inline_attribute (node, name, args, flags, no_add_attrs) ...@@ -5415,16 +5415,19 @@ handle_always_inline_attribute (node, name, args, flags, no_add_attrs)
struct attribute_spec.handler. */ struct attribute_spec.handler. */
static tree static tree
handle_used_attribute (node, name, args, flags, no_add_attrs) handle_used_attribute (pnode, name, args, flags, no_add_attrs)
tree *node; tree *pnode;
tree name; tree name;
tree args ATTRIBUTE_UNUSED; tree args ATTRIBUTE_UNUSED;
int flags ATTRIBUTE_UNUSED; int flags ATTRIBUTE_UNUSED;
bool *no_add_attrs; bool *no_add_attrs;
{ {
if (TREE_CODE (*node) == FUNCTION_DECL) tree node = *pnode;
TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (*node))
= TREE_USED (*node) = 1; 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 else
{ {
warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name)); warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
......
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> 2003-02-18 Mark Mitchell <mark@codesourcery.com>
PR c++/9704 PR c++/9704
......
...@@ -43,7 +43,7 @@ struct ATSYM(struct) { ...@@ -43,7 +43,7 @@ struct ATSYM(struct) {
char dummy ATTR; /* { dg-warning "attribute ignored" "" } */ char dummy ATTR; /* { dg-warning "attribute ignored" "" } */
} ATTR; /* { dg-warning "does not apply to types" "" } */ } 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 ATSYM(fn_knrarg) (arg)
int arg ATTR; /* { dg-warning "attribute ignored" "" } */ int arg ATTR; /* { dg-warning "attribute ignored" "" } */
...@@ -52,7 +52,7 @@ int ATSYM(fn_knrarg) (arg) ...@@ -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_isoarg) (int arg ATTR) { return 0; } /* { dg-warning "attribute ignored" "" } */
int ATSYM(fn_vars) (void) { 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" "" } */ auto int lvar ATTR; /* { dg-warning "attribute ignored" "" } */
return 0; return 0;
} }
/* { 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" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment