diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2001-10-18 18:27:48 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@gcc.gnu.org> | 2001-10-18 18:27:48 +0000 |
commit | 97055d5c4e5ce6792523800bbd326313f81a48ef (patch) | |
tree | fe348fad82fd390d947736dda47c32dc99de8dea /gcc | |
parent | c586d12794533da0614e70b7d17cd01ab8ebf049 (diff) | |
download | gcc-97055d5c4e5ce6792523800bbd326313f81a48ef.zip gcc-97055d5c4e5ce6792523800bbd326313f81a48ef.tar.gz gcc-97055d5c4e5ce6792523800bbd326313f81a48ef.tar.bz2 |
decl.c (duplicate_decls): Propagate DECL_UNINLINABLE.
* decl.c (duplicate_decls): Propagate DECL_UNINLINABLE.
Warn when merging inline with attribute noinline.
(start_decl, start_function): Warn if inline and attribute
noinline appear in the same declaration.
From-SVN: r46333
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 48 |
2 files changed, 55 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e606952..8a3f10b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2001-10-18 Alexandre Oliva <aoliva@redhat.com> + + * decl.c (duplicate_decls): Propagate DECL_UNINLINABLE. + Warn when merging inline with attribute noinline. + (start_decl, start_function): Warn if inline and attribute + noinline appear in the same declaration. + 2001-10-16 H.J. Lu <hjl@gnu.org> * cp-tree.h (BOUND_TEMPLATE_TEMPLATE_PARM_TYPE_CHECK): Defined diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e499cdb..bd64bc4 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -3093,6 +3093,39 @@ duplicate_decls (newdecl, olddecl) || TREE_TYPE (olddecl) == error_mark_node) types_match = 1; + if (DECL_P (olddecl) + && TREE_CODE (newdecl) == FUNCTION_DECL + && TREE_CODE (olddecl) == FUNCTION_DECL + && (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl))) + { + if (DECL_DECLARED_INLINE_P (newdecl) + && DECL_UNINLINABLE (newdecl) + && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) + /* Already warned elsewhere. */; + else if (DECL_DECLARED_INLINE_P (olddecl) + && DECL_UNINLINABLE (olddecl) + && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) + /* Already warned. */; + else if (DECL_DECLARED_INLINE_P (newdecl) + && DECL_UNINLINABLE (olddecl) + && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) + { + warning_with_decl (newdecl, + "function `%s' redeclared as inline"); + warning_with_decl (olddecl, + "previous declaration of function `%s' with attribute noinline"); + } + else if (DECL_DECLARED_INLINE_P (olddecl) + && DECL_UNINLINABLE (newdecl) + && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) + { + warning_with_decl (newdecl, + "function `%s' redeclared with attribute noinline"); + warning_with_decl (olddecl, + "previous declaration of function `%s' was inline"); + } + } + /* Check for redeclaration and other discrepancies. */ if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_ARTIFICIAL (olddecl)) @@ -3640,6 +3673,9 @@ duplicate_decls (newdecl, olddecl) DECL_INLINE (olddecl) = 1; DECL_INLINE (newdecl) = DECL_INLINE (olddecl); + DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl) + = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl)); + /* Preserve abstractness on cloned [cd]tors. */ DECL_ABSTRACT (newdecl) = DECL_ABSTRACT (olddecl); @@ -7132,6 +7168,13 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes) /* Set attributes here so if duplicate decl, will have proper attributes. */ cplus_decl_attributes (&decl, attributes, 0); + if (TREE_CODE (decl) == FUNCTION_DECL + && DECL_DECLARED_INLINE_P (decl) + && DECL_UNINLINABLE (decl) + && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) + warning_with_decl (decl, + "inline function `%s' given attribute noinline"); + if (context && COMPLETE_TYPE_P (complete_type (context))) { push_nested_class (context, 2); @@ -13328,6 +13371,11 @@ start_function (declspecs, declarator, attrs, flags) } } + if (DECL_DECLARED_INLINE_P (decl1) + && lookup_attribute ("noinline", attrs)) + warning_with_decl (decl1, + "inline function `%s' given attribute noinline"); + if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl1)) /* This is a constructor, we must ensure that any default args introduced by this definition are propagated to the clones |