This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[3.3 PATCH] Fix -Winline
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 11 Jun 2003 11:32:28 +0200
- Subject: [3.3 PATCH] Fix -Winline
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
Following test results in:
test.c:5: warning: inlining failed in call to `baz'
test.h:12: warning: called from here
(note test.h:12 instead of the expected test.c:12).
This bug is not present on mainline because of the location changes,
but I wonder if it is not worth fixing on 3.3 branch as well.
The patch below fixes it for me and is moreless what the C++ frontend
does in this case as well.
/* { dg-do compile } */
/* { dg-options "-O3 -Winline -fpreprocessed" } */
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
# 1 "test.h" 1
static inline void __attribute__ ((unused))
foo (void)
{
}
static inline void __attribute__ ((unused))
bar (void)
{
foo ();
}
# 2 "test.c" 2
static void baz (void);
static void
baz (void)
{
void *dummy = __builtin_alloca (10);
}
void
test (void)
{
baz ();
}
2003-06-11 Jakub Jelinek <jakub@redhat.com>
* c-decl.c (c_expand_body): Save input_filename and lineno,
set it before tree inlining and restore before return.
--- gcc/c-decl.c.jj 2003-06-10 18:39:55.000000000 -0400
+++ gcc/c-decl.c 2003-06-10 19:37:00.000000000 -0400
@@ -6496,12 +6496,19 @@ c_expand_body (fndecl, nested_p, can_def
int nested_p, can_defer_p;
{
int uninlinable = 1;
+ int saved_lineno;
+ const char *saved_input_filename;
/* There's no reason to do any of the work here if we're only doing
semantic analysis; this code just generates RTL. */
if (flag_syntax_only)
return;
+ saved_lineno = lineno;
+ saved_input_filename = input_filename;
+ lineno = DECL_SOURCE_LINE (fndecl);
+ input_filename = DECL_SOURCE_FILE (fndecl);
+
if (flag_inline_trees)
{
/* First, cache whether the current function is inlinable. Some
@@ -6519,6 +6526,8 @@ c_expand_body (fndecl, nested_p, can_def
/* Let the back-end know that this function exists. */
(*debug_hooks->deferred_inline_function) (fndecl);
timevar_pop (TV_INTEGRATION);
+ lineno = saved_lineno;
+ input_filename = saved_input_filename;
return;
}
@@ -6540,7 +6549,6 @@ c_expand_body (fndecl, nested_p, can_def
/* Initialize the RTL code for the function. */
current_function_decl = fndecl;
- input_filename = DECL_SOURCE_FILE (fndecl);
init_function_start (fndecl, input_filename, DECL_SOURCE_LINE (fndecl));
/* This function is being processed in whole-function mode. */
@@ -6677,6 +6685,9 @@ c_expand_body (fndecl, nested_p, can_def
/* Return to the enclosing function. */
pop_function_context ();
timevar_pop (TV_EXPAND);
+
+ lineno = saved_lineno;
+ input_filename = saved_input_filename;
}
/* Check the declarations given in a for-loop for satisfying the C99
Jakub