This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C++ patch] warnings for -Winline
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rth at redhat dot com
- Date: Tue, 9 Sep 2003 20:46:29 +0200
- Subject: [C++ patch] warnings for -Winline
Hi,
this patch adds warnings into cp_cannot_inline_tree_fn.
Any idea why we prohibit inlining for functions that need instantiating?
It produces crazy warnins and removing the test appears to cause no
harm.
Honza
Tue Sep 9 20:36:08 CEST 2003 Jan Hubicka <jh@suse.cz>
* tree.c (cp_cannot_inline_tree_fn): Add warnings.
diff -Nrc3p gcc.old3/cp/tree.c gcc/cp/tree.c
*** gcc.old3/cp/tree.c Tue Sep 9 17:06:17 2003
--- gcc/cp/tree.c Tue Sep 9 20:05:39 2003
*************** int
*** 2062,2103 ****
cp_cannot_inline_tree_fn (tree* fnp)
{
tree fn = *fnp;
/* We can inline a template instantiation only if it's fully
instantiated. */
if (DECL_TEMPLATE_INFO (fn)
&& TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
{
- /* Don't instantiate functions that are not going to be
- inlined. */
- if (!DECL_INLINE (DECL_TEMPLATE_RESULT
- (template_for_substitution (fn))))
- return 1;
fn = *fnp = instantiate_decl (fn, /*defer_ok=*/0);
if (TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
! return 1;
}
if (flag_really_no_inline
&& lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
! return 1;
/* Don't auto-inline anything that might not be bound within
this unit of translation. */
if (!DECL_DECLARED_INLINE_P (fn) && !(*targetm.binds_local_p) (fn))
{
DECL_UNINLINABLE (fn) = 1;
return 1;
}
if (varargs_function_p (fn))
{
DECL_UNINLINABLE (fn) = 1;
return 1;
}
if (! function_attribute_inlinable_p (fn))
{
DECL_UNINLINABLE (fn) = 1;
return 1;
}
--- 2062,2126 ----
cp_cannot_inline_tree_fn (tree* fnp)
{
tree fn = *fnp;
+ bool do_warning = (warn_inline
+ && DECL_INLINE (fn)
+ && DECL_DECLARED_INLINE_P (fn)
+ && !DECL_IN_SYSTEM_HEADER (fn));
/* We can inline a template instantiation only if it's fully
instantiated. */
if (DECL_TEMPLATE_INFO (fn)
&& TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
{
fn = *fnp = instantiate_decl (fn, /*defer_ok=*/0);
if (TI_PENDING_TEMPLATE_FLAG (DECL_TEMPLATE_INFO (fn)))
! {
! if (do_warning)
! warning ("%Hfunction '%F' can never be inlined because it "
! "is pending to be instantiated",
! &DECL_SOURCE_LOCATION (fn), fn);
! return 1;
! }
}
if (flag_really_no_inline
&& lookup_attribute ("always_inline", DECL_ATTRIBUTES (fn)) == NULL)
! {
! if (do_warning)
! warning ("%Hfunction '%F' can never be inlined because it "
! "is supressed using -fno-really-inline",
! &DECL_SOURCE_LOCATION (fn), fn);
! return 1;
! }
/* Don't auto-inline anything that might not be bound within
this unit of translation. */
if (!DECL_DECLARED_INLINE_P (fn) && !(*targetm.binds_local_p) (fn))
{
DECL_UNINLINABLE (fn) = 1;
+ if (do_warning)
+ warning ("%Hfunction '%F' can never be inlined because it might not "
+ "be bound within this unit of translation",
+ &DECL_SOURCE_LOCATION (fn), fn);
return 1;
}
if (varargs_function_p (fn))
{
+ if (do_warning)
+ warning ("%Hfunction '%F' can never be inlined because it use "
+ "variable argument lists",
+ &DECL_SOURCE_LOCATION (fn), fn);
DECL_UNINLINABLE (fn) = 1;
return 1;
}
if (! function_attribute_inlinable_p (fn))
{
+ if (do_warning)
+ warning ("%Hfunction '%F' can never be inlined because it use "
+ "attributes conflicting with inlining",
+ &DECL_SOURCE_LOCATION (fn), fn);
DECL_UNINLINABLE (fn) = 1;
return 1;
}