function.h (struct function): Add function_start_locus.

* function.h (struct function): Add function_start_locus.
        * cfgexpand.c (gimple_expand_cfg): Use it.
        * c-parser.c (c_parser_declaration_or_fndef): Set it.
testsuite/
        * gcc.dg/always_inline.c: Place error message on function
        name line.
        * gcc.dg/winline-6.c: Same.
        * gcc.dg/noreturn-1.c: Same.
        * gcc.dg/noreturn-7.c: Same.
        * gcc.dg/inline-14.c: Same.
        * gcc.dg/always_inline3.c: Same.
        * gcc.dg/winline-3.c: Same.
        * gcc.dg/wtr-func-def-1.c: Same.
        * gcc.dg/winline-5.c: Same.
        * gcc.dg/winline-7.c: Same.
        * gcc.dg/winline-9.c: Same.
        * gcc.dg/noreturn-4.c: Same.
        * gcc.dg/20041213-1.c: Use column numbers.

From-SVN: r140144
This commit is contained in:
Aldy Hernandez 2008-09-09 10:56:23 +00:00 committed by Aldy Hernandez
parent a135b1c41c
commit 1751ecd619
18 changed files with 113 additions and 80 deletions

View File

@ -1,3 +1,9 @@
2008-09-09 Aldy Hernandez <aldyh@redhat.com>
* function.h (struct function): Add function_start_locus.
* cfgexpand.c (gimple_expand_cfg): Use it.
* c-parser.c (c_parser_declaration_or_fndef): Set it.
2008-09-09 Richard Guenther <rguenther@suse.de> 2008-09-09 Richard Guenther <rguenther@suse.de>
PR tree-optimization/37433 PR tree-optimization/37433

View File

@ -1301,9 +1301,9 @@ c_parser_declaration_or_fndef (c_parser *parser, bool fndef_ok, bool empty_ok,
while (c_parser_next_token_is_not (parser, CPP_EOF) while (c_parser_next_token_is_not (parser, CPP_EOF)
&& c_parser_next_token_is_not (parser, CPP_OPEN_BRACE)) && c_parser_next_token_is_not (parser, CPP_OPEN_BRACE))
c_parser_declaration_or_fndef (parser, false, false, true, false); c_parser_declaration_or_fndef (parser, false, false, true, false);
DECL_SOURCE_LOCATION (current_function_decl)
= c_parser_peek_token (parser)->location;
store_parm_decls (); store_parm_decls ();
DECL_STRUCT_FUNCTION (current_function_decl)->function_start_locus
= c_parser_peek_token (parser)->location;
fnbody = c_parser_compound_statement (parser); fnbody = c_parser_compound_statement (parser);
if (nested) if (nested)
{ {

View File

@ -2261,7 +2261,14 @@ gimple_expand_cfg (void)
insn_locators_alloc (); insn_locators_alloc ();
if (!DECL_BUILT_IN (current_function_decl)) if (!DECL_BUILT_IN (current_function_decl))
set_curr_insn_source_location (DECL_SOURCE_LOCATION (current_function_decl)); {
/* Eventually, all FEs should explicitly set function_start_locus. */
if (cfun->function_start_locus == UNKNOWN_LOCATION)
set_curr_insn_source_location
(DECL_SOURCE_LOCATION (current_function_decl));
else
set_curr_insn_source_location (cfun->function_start_locus);
}
set_curr_insn_block (DECL_INITIAL (current_function_decl)); set_curr_insn_block (DECL_INITIAL (current_function_decl));
prologue_locator = curr_insn_locator (); prologue_locator = curr_insn_locator ();

View File

@ -527,6 +527,9 @@ struct function GTY(())
/* Last statement uid. */ /* Last statement uid. */
int last_stmt_uid; int last_stmt_uid;
/* Line number of the start of the function for debugging purposes. */
location_t function_start_locus;
/* Line number of the end of the function. */ /* Line number of the end of the function. */
location_t function_end_locus; location_t function_end_locus;

View File

@ -1,3 +1,20 @@
2008-09-09 Aldy Hernandez <aldyh@redhat.com>
* gcc.dg/always_inline.c: Place error message on function
name line.
* gcc.dg/winline-6.c: Same.
* gcc.dg/noreturn-1.c: Same.
* gcc.dg/noreturn-7.c: Same.
* gcc.dg/inline-14.c: Same.
* gcc.dg/always_inline3.c: Same.
* gcc.dg/winline-3.c: Same.
* gcc.dg/wtr-func-def-1.c: Same.
* gcc.dg/winline-5.c: Same.
* gcc.dg/winline-7.c: Same.
* gcc.dg/winline-9.c: Same.
* gcc.dg/noreturn-4.c: Same.
* gcc.dg/20041213-1.c: Use column numbers.
2008-09-09 Richard Guenther <rguenther@suse.de> 2008-09-09 Richard Guenther <rguenther@suse.de>
PR tree-optimization/37433 PR tree-optimization/37433

View File

@ -1,33 +1,33 @@
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "" } */ /* { dg-options "-fshow-column" } */
/* test redeclarations with void and implicit int */ /* test redeclarations with void and implicit int */
extern foo1(); /* { dg-message "note: previous declaration" } */ extern foo1(); /* { dg-message "8:note: previous declaration" } */
extern void foo1(); /* { dg-error "conflicting types" } */ extern void foo1(); /* { dg-error "13:conflicting types" } */
extern void foo2(); /* { dg-message "note: previous declaration" } */ extern void foo2(); /* { dg-message "13:note: previous declaration" } */
extern foo2(); /* { dg-error "conflicting types" } */ extern foo2(); /* { dg-error "8:conflicting types" } */
void foo3() {} /* { dg-message "note: previous definition" } */ void foo3() {} /* { dg-message "6:note: previous definition" } */
extern foo3(); /* { dg-error "conflicting types" } */ extern foo3(); /* { dg-error "8:conflicting types" } */
extern foo4(); /* { dg-message "note: previous declaration" } */ extern foo4(); /* { dg-message "8:note: previous declaration" } */
void foo4() {} /* { dg-error "conflicting types" } */ void foo4() {} /* { dg-error "6:conflicting types" } */
extern void foo5(); /* { dg-message "note: previous declaration" } */ extern void foo5(); /* { dg-message "13:note: previous declaration" } */
foo5() {} /* { dg-warning "conflicting types" } */ foo5() {} /* { dg-warning "1:conflicting types" } */
foo6() {} /* { dg-message "note: previous definition" } */ foo6() {} /* { dg-message "1:note: previous definition" } */
extern void foo6(); /* { dg-error "conflicting types" } */ extern void foo6(); /* { dg-error "13:conflicting types" } */
foo7() {} /* { dg-message "note: previous definition" } */ foo7() {} /* { dg-message "1:note: previous definition" } */
void foo7() {} /* { dg-error "conflicting types" } */ void foo7() {} /* { dg-error "6:conflicting types" } */
void foo8() {} /* { dg-message "note: previous definition" } */ void foo8() {} /* { dg-message "6:note: previous definition" } */
foo8() {} /* { dg-error "conflicting types" } */ foo8() {} /* { dg-error "1:conflicting types" } */
int use9() { foo9(); } /* { dg-message "note: previous implicit declaration" } */ int use9() { foo9(); } /* { dg-message "note: previous implicit declaration" } */
extern void foo9(); /* { dg-warning "conflicting types" } */ extern void foo9(); /* { dg-warning "13:conflicting types" } */
int use10() { foo10(); } /* { dg-message "note: previous implicit declaration" } */ int use10() { foo10(); } /* { dg-message "note: previous implicit declaration" } */
void foo10() {} /* { dg-warning "conflicting types" } */ void foo10() {} /* { dg-warning "6:conflicting types" } */

View File

@ -2,8 +2,8 @@
/* { dg-options "-Winline -O2" } */ /* { dg-options "-Winline -O2" } */
#include <stdarg.h> #include <stdarg.h>
inline __attribute__ ((always_inline)) void inline __attribute__ ((always_inline)) void
e(int t, ...) e(int t, ...) /* { dg-message "sorry\[^\n\]*variable argument" "" } */
{ /* { dg-message "sorry\[^\n\]*variable argument" "" } */ {
va_list q; va_list q;
va_start (q, t); va_start (q, t);
} }

View File

@ -2,8 +2,8 @@
/* { dg-options "-Winline -O2" } */ /* { dg-options "-Winline -O2" } */
int do_something_evil (void); int do_something_evil (void);
inline __attribute__ ((always_inline)) void inline __attribute__ ((always_inline)) void
q2(void) q2(void) /* { dg-message "sorry\[^\n\]*recursive" "" } */
{ /* { dg-message "sorry\[^\n\]*recursive" "" } */ {
if (do_something_evil ()) if (do_something_evil ())
return; return;
q2(); /* { dg-message "sorry\[^\n\]*called from here" "" } */ q2(); /* { dg-message "sorry\[^\n\]*called from here" "" } */

View File

@ -2,8 +2,8 @@
/* { dg-do compile } */ /* { dg-do compile } */
/* { dg-options "-std=c99" } */ /* { dg-options "-std=c99" } */
extern inline int func1 (void) extern inline int func1 (void) /* { dg-message "note: previous definition" } */
{ /* { dg-message "note: previous definition" } */ {
return 1; return 1;
} }
@ -12,8 +12,8 @@ inline int func1 (void) /* { dg-error "redefinition" } */
return 1; return 1;
} }
inline int func2 (void) inline int func2 (void) /* { dg-message "note: previous definition" } */
{ /* { dg-message "note: previous definition" } */ {
return 2; return 2;
} }

View File

@ -25,8 +25,8 @@ foo3(void)
extern void foo4(void); extern void foo4(void);
void void
foo4(void) foo4(void) /* { dg-warning "candidate for attribute 'noreturn'" "detect noreturn candidate" } */
{ /* { dg-warning "candidate for attribute 'noreturn'" "detect noreturn candidate" } */ {
exit(0); exit(0);
} }

View File

@ -4,7 +4,7 @@
extern void exit (int) __attribute__ ((__noreturn__)); extern void exit (int) __attribute__ ((__noreturn__));
int int
main (void) main (void) /* { dg-warning "function might be possible candidate for attribute 'noreturn'" "warn for main" } */
{ /* { dg-warning "function might be possible candidate for attribute 'noreturn'" "warn for main" } */ {
exit (0); exit (0);
} }

View File

@ -13,8 +13,8 @@ void _exit(int status) __attribute__ ((__noreturn__));
int z = 0; int z = 0;
void g() void g() /* { dg-warning "possible candidate" } */
{ /* { dg-warning "possible candidate" } */ {
if (++z > 10) if (++z > 10)
_exit(0); _exit(0);
g(); g();
@ -27,15 +27,15 @@ void f()
f(); f();
} /* { dg-bogus "does return" } */ } /* { dg-bogus "does return" } */
int h() int h() /* { dg-warning "possible candidate" } */
{ /* { dg-warning "possible candidate" } */ {
if (++z > 10) if (++z > 10)
_exit(0); _exit(0);
return h(); return h();
} /* { dg-bogus "end of non-void function" } */ } /* { dg-bogus "end of non-void function" } */
int k() int k() /* { dg-warning "possible candidate" } */
{ /* { dg-warning "possible candidate" } */ {
if (++z > 10) if (++z > 10)
_exit(0); _exit(0);
k(); k();

View File

@ -2,8 +2,8 @@
/* { dg-options "-Winline -O2 --param max-inline-insns-single=1" } */ /* { dg-options "-Winline -O2 --param max-inline-insns-single=1" } */
void big (void); void big (void);
inline int q(void) inline int q(void) /* { dg-warning "max-inline-insns-single" "" } */
{ /* { dg-warning "max-inline-insns-single" "" } */ {
big(); big();
big(); big();
big(); big();

View File

@ -2,8 +2,8 @@
/* { dg-options "-Winline -O2 --param inline-unit-growth=0 --param large-unit-insns=0" } */ /* { dg-options "-Winline -O2 --param inline-unit-growth=0 --param large-unit-insns=0" } */
void big (void); void big (void);
inline int q(void) inline int q(void) /* { dg-warning "inline-unit-growth" } */
{ /* { dg-warning "inline-unit-growth" } */ {
big(); big();
big(); big();
big(); big();

View File

@ -2,8 +2,8 @@
/* { dg-options "-Winline -O2 --param large-function-growth=0 --param large-function-insns=1" } */ /* { dg-options "-Winline -O2 --param large-function-growth=0 --param large-function-insns=1" } */
void big (void); void big (void);
inline int q(void) inline int q(void) /* { dg-warning "large-function-growth" } */
{ /* { dg-warning "large-function-growth" } */ {
big(); big();
big(); big();
big(); big();

View File

@ -4,8 +4,8 @@
extern void *alloca (__SIZE_TYPE__); extern void *alloca (__SIZE_TYPE__);
void big (void); void big (void);
inline void *q (void) inline void *q (void) /* { dg-warning "(function not inlinable|alloca)" } */
{ /* { dg-warning "(function not inlinable|alloca)" } */ {
return alloca (10); return alloca (10);
} }
inline void *t (void) inline void *t (void)

View File

@ -10,8 +10,8 @@ int aa (void)
test(t); test(t);
} }
static inline static inline
int bb (void) int bb (void) /* { dg-warning "large-stack-frame" "" } */
{ /* { dg-warning "large-stack-frame" "" } */ {
char t[100]; char t[100];
test(t); test(t);
} }

View File

@ -6,8 +6,8 @@
/* Test some simple cases. */ /* Test some simple cases. */
void f_void1 (void) void f_void1 (void) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
@ -16,8 +16,8 @@ void f_void2 ()
return; return;
} }
void f_int1 (int f) void f_int1 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
@ -29,8 +29,8 @@ void f_int2 (f)
/* Test that we don't ever warn about nested functions. */ /* Test that we don't ever warn about nested functions. */
void f_int3 (int f) void f_int3 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
void f3a (void) { return; } void f3a (void) { return; }
void f3b () { return; } void f3b () { return; }
void f3c (int f) { return; } void f3c (int f) { return; }
@ -39,8 +39,8 @@ void f_int3 (int f)
return; return;
} }
void f_int4 (int f) void f_int4 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
void f4a (void) { return; } void f4a (void) { return; }
void f4b () { return; } void f4b () { return; }
void f4c (int f) { return; } void f4c (int f) { return; }
@ -77,14 +77,14 @@ void f_int6 (f)
are still warned about. */ are still warned about. */
extern void f_int_p1 (int); extern void f_int_p1 (int);
void f_int_p1 (int f) void f_int_p1 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
extern void f_int_p2 (int f); extern void f_int_p2 (int f);
void f_int_p2 (int f) void f_int_p2 (int f) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
@ -103,14 +103,14 @@ void f_int_p4 (f)
} }
extern void f_void_p1 (); extern void f_void_p1 ();
void f_void_p1 (void) void f_void_p1 (void) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
extern void f_void_p2 (void); extern void f_void_p2 (void);
void f_void_p2 (void) void f_void_p2 (void) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
@ -133,39 +133,39 @@ f_impl1()
return 0; return 0;
} }
f_impl2(void) f_impl2(void) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return 0; return 0;
} }
f_impl3(int f) f_impl3(int f) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return 0; return 0;
} }
/* Test stdarg functions. */ /* Test stdarg functions. */
f_stdarg1(const char *s, ...) f_stdarg1(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return 0; return 0;
} }
void f_stdarg2(const char *s, ...) void f_stdarg2(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
extern void f_stdarg3(const char *, ...); extern void f_stdarg3(const char *, ...);
void f_stdarg3(const char *s, ...) void f_stdarg3(const char *s, ...) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
/* Test handling function pointer parameters. */ /* Test handling function pointer parameters. */
void f_fnptr1 (int f, int (*fp)(int)); void f_fnptr1 (int f, int (*fp)(int));
void f_fnptr1 (int f, int (*fp)(int)) void f_fnptr1 (int f, int (*fp)(int)) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return; return;
} }
@ -180,8 +180,8 @@ void f_fnptr2 (f, fp)
/* Test for main. */ /* Test for main. */
int int
main (int argc, char **argv) main (int argc, char **argv) /* { dg-warning "traditional C rejects ISO C style" } */
{ /* { dg-warning "traditional C rejects ISO C style" } */ {
return 0; return 0;
} }