From 6b4e94bcaef89af9899da67f2dffc54496120535 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Thu, 27 Mar 2008 16:34:55 +0000 Subject: [PATCH] re PR c/32511 (GCC rejects inline+weak function) 2008-03-27 Richard Guenther PR c/32511 * c-common.c (handle_weak_attribute): Reject combination of weak and inline. * gcc.dg/attr-weak-1.c: New testcase. From-SVN: r133646 --- gcc/ChangeLog | 6 ++++++ gcc/c-common.c | 9 +++++++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/attr-weak-1.c | 4 ++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/attr-weak-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 215f0b26728..19cb5670f75 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-03-27 Richard Guenther + + PR c/32511 + * c-common.c (handle_weak_attribute): Reject combination of + weak and inline. + 2008-03-27 Richard Guenther PR tree-optimization/32810 diff --git a/gcc/c-common.c b/gcc/c-common.c index 1b629745239..7e609deeb50 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -5518,11 +5518,16 @@ handle_weak_attribute (tree *node, tree name, bool * ARG_UNUSED (no_add_attrs)) { if (TREE_CODE (*node) == FUNCTION_DECL - || TREE_CODE (*node) == VAR_DECL) + && DECL_DECLARED_INLINE_P (*node)) + { + error ("inline function %q+D cannot be declared weak", *node); + *no_add_attrs = true; + } + else 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 abaed69e399..175289686e6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2008-03-27 Richard Guenther + + PR c/32511 + * gcc.dg/attr-weak-1.c: New testcase. + 2008-03-27 Richard Guenther PR tree-optimization/32810 diff --git a/gcc/testsuite/gcc.dg/attr-weak-1.c b/gcc/testsuite/gcc.dg/attr-weak-1.c new file mode 100644 index 00000000000..014e37d4d9a --- /dev/null +++ b/gcc/testsuite/gcc.dg/attr-weak-1.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ + +__inline void foo(void) __attribute__((weak)); /* { dg-error "inline.*weak" } */ + -- 2.30.2