aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-decl.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2001-10-18 18:29:02 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2001-10-18 18:29:02 +0000
commit9162542e3d0cd270ab972615f66d7da16662466d (patch)
treeba59c40e9652d1cafe3687880cd7a3e173e06791 /gcc/c-decl.c
parent97055d5c4e5ce6792523800bbd326313f81a48ef (diff)
downloadgcc-9162542e3d0cd270ab972615f66d7da16662466d.zip
gcc-9162542e3d0cd270ab972615f66d7da16662466d.tar.gz
gcc-9162542e3d0cd270ab972615f66d7da16662466d.tar.bz2
attribs.c (handle_noinline_attribute): New function.
* attribs.c (handle_noinline_attribute): New function. (handle_used_attribute): Likewise. (c_common_attribute_table): Added noinline and used. * doc/extend.texi (Function Attributes): Document them. * c-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: r46334
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r--gcc/c-decl.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index ee45b8f..de553b1 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -1405,8 +1405,43 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
int errmsg = 0;
if (DECL_P (olddecl))
- DECL_ATTRIBUTES (newdecl)
- = (*targetm.merge_decl_attributes) (olddecl, newdecl);
+ {
+ if (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_DECLARED_INLINE_P (olddecl)
+ && 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");
+ }
+ }
+
+ DECL_ATTRIBUTES (newdecl)
+ = (*targetm.merge_decl_attributes) (olddecl, newdecl);
+ }
if (TREE_CODE (newtype) == ERROR_MARK
|| TREE_CODE (oldtype) == ERROR_MARK)
@@ -1983,6 +2018,9 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
DECL_DECLARED_INLINE_P (olddecl) = 1;
DECL_DECLARED_INLINE_P (newdecl) = DECL_DECLARED_INLINE_P (olddecl);
+
+ DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl)
+ = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl));
}
if (DECL_BUILT_IN (olddecl))
@@ -3483,6 +3521,13 @@ start_decl (declarator, declspecs, initialized, attributes)
/* Set attributes here so if duplicate decl, will have proper attributes. */
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");
+
/* Add this decl to the current binding level.
TEM may equal DECL or it may be a previous decl of the same name. */
tem = pushdecl (decl);
@@ -6022,6 +6067,12 @@ start_function (declspecs, declarator, attributes)
decl_attributes (&decl1, attributes, 0);
+ if (DECL_DECLARED_INLINE_P (decl1)
+ && DECL_UNINLINABLE (decl1)
+ && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1)))
+ warning_with_decl (decl1,
+ "inline function `%s' given attribute noinline");
+
announce_function (decl1);
if (!COMPLETE_OR_VOID_TYPE_P (TREE_TYPE (TREE_TYPE (decl1))))