From e7b012c0443aa04b8b128e64fa1a5e193c8cc340 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 26 Sep 2008 07:09:29 +0200 Subject: [PATCH] re PR c/37645 (ICE with weakref attribute) PR c/37645 * c-common.c (handle_weakref_attribute): Ignore the attribute unless the decl is a VAR_DECL or FUNCTION_DECL. * gcc.dg/pr37645.c: New test. From-SVN: r140680 --- gcc/ChangeLog | 8 ++++++-- gcc/c-common.c | 4 +++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr37645.c | 5 +++++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/pr37645.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 86d2c46d6a90..66031cc705f7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,7 +1,12 @@ +2008-09-25 Jakub Jelinek + + PR c/37645 + * c-common.c (handle_weakref_attribute): Ignore the attribute unless + the decl is a VAR_DECL or FUNCTION_DECL. + 2008-09-25 Vladimir Makarov PR middle-end/37535 - * ira-lives.c (mark_reg_live, mark_reg_dead): New functions. (mark_ref_live, mark_ref_dead): Use them. (def_conflicts_with_inputs_p): Remove. @@ -14,7 +19,6 @@ 2008-09-25 Vladimir Makarov PR middle-end/37448 - * ira-int.h (IRA_ALLOCNO_TEMP): Rename to ALLOCNO_TEMP. (ira_compress_allocno_live_ranges): New prototype. diff --git a/gcc/c-common.c b/gcc/c-common.c index 680b9b56651b..5d692112bd70 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -6131,7 +6131,9 @@ handle_weakref_attribute (tree *node, tree ARG_UNUSED (name), tree args, /* We must ignore the attribute when it is associated with local-scoped decls, since attribute alias is ignored and many such symbols do not even have a DECL_WEAK field. */ - if (decl_function_context (*node) || current_function_decl) + if (decl_function_context (*node) + || current_function_decl + || (TREE_CODE (*node) != VAR_DECL && TREE_CODE (*node) != FUNCTION_DECL)) { warning (OPT_Wattributes, "%qE attribute ignored", name); *no_add_attrs = true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7cf9972bf0f0..959ab49ff8a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-09-25 Jakub Jelinek + + PR c/37645 + * gcc.dg/pr37645.c: New test. + 2008-09-25 Steve Ellcey * gcc.dg/vect/slp-7.c: Add alignment attribute, change target tests. diff --git a/gcc/testsuite/gcc.dg/pr37645.c b/gcc/testsuite/gcc.dg/pr37645.c new file mode 100644 index 000000000000..ac1e5a9d1c81 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr37645.c @@ -0,0 +1,5 @@ +/* PR c/37645 */ +/* { dg-do compile } */ + +typedef int T __attribute__((__weakref__ ("U"))); /* { dg-warning "attribute ignored" } */ +void foo (int i __attribute__((__weakref__ ("j")))); /* { dg-warning "attribute ignored" } */ -- 2.47.3