From 8c37d3591562e19a7820e8d8c1186f9e5e5f9d60 Mon Sep 17 00:00:00 2001 From: tromey Date: Thu, 1 Nov 2007 15:31:12 +0000 Subject: [PATCH] gcc * c-decl.c (grokdeclarator): Set decl source locations. * c-parser.c (c_parser_enum_specifier): Set location. (c_parser_struct_or_union_specifier): Likewise. gcc/testsuite * gcc.dg/redecl-1.c: Update. * gcc.dg/pr20368-3.c: Update. * gcc.dg/inline-14.c: Update. * gcc.dg/builtins-30.c: Update. * gcc.dg/dremf-type-compat-4.c: Update. * gcc.dg/pr20368-2.c: Update. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129822 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 6 ++++++ gcc/c-decl.c | 4 ++++ gcc/c-parser.c | 10 +++++++++- gcc/testsuite/ChangeLog | 9 +++++++++ gcc/testsuite/gcc.dg/builtins-30.c | 12 ++++++------ gcc/testsuite/gcc.dg/dremf-type-compat-4.c | 4 ++-- gcc/testsuite/gcc.dg/inline-14.c | 8 ++++---- gcc/testsuite/gcc.dg/pr20368-2.c | 4 ++-- gcc/testsuite/gcc.dg/pr20368-3.c | 4 ++-- gcc/testsuite/gcc.dg/redecl-1.c | 12 ++++++------ 10 files changed, 50 insertions(+), 23 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 68ec0edc3b2..7363e529936 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,11 @@ 2007-11-01 Tom Tromey + * c-decl.c (grokdeclarator): Set decl source locations. + * c-parser.c (c_parser_enum_specifier): Set location. + (c_parser_struct_or_union_specifier): Likewise. + +2007-11-01 Tom Tromey + * print-tree.c (print_node): Print column number. 2007-11-01 Jakub Jelinek diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 1152253e2e2..5ddbcc0772a 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4645,6 +4645,7 @@ grokdeclarator (const struct c_declarator *declarator, if (type_quals) type = c_build_qualified_type (type, type_quals); decl = build_decl (TYPE_DECL, declarator->u.id, type); + DECL_SOURCE_LOCATION (decl) = declarator->id_loc; if (declspecs->explicit_signed_p) C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1; if (declspecs->inline_p) @@ -4740,6 +4741,7 @@ grokdeclarator (const struct c_declarator *declarator, type_as_written = type; decl = build_decl (PARM_DECL, declarator->u.id, type); + DECL_SOURCE_LOCATION (decl) = declarator->id_loc; if (size_varies) C_DECL_VARIABLE_SIZE (decl) = 1; @@ -4779,6 +4781,7 @@ grokdeclarator (const struct c_declarator *declarator, } type = c_build_qualified_type (type, type_quals); decl = build_decl (FIELD_DECL, declarator->u.id, type); + DECL_SOURCE_LOCATION (decl) = declarator->id_loc; DECL_NONADDRESSABLE_P (decl) = bitfield; if (bitfield && !declarator->u.id) TREE_NO_WARNING (decl) = 1; @@ -4815,6 +4818,7 @@ grokdeclarator (const struct c_declarator *declarator, } decl = build_decl (FUNCTION_DECL, declarator->u.id, type); + DECL_SOURCE_LOCATION (decl) = declarator->id_loc; decl = build_decl_attribute_variant (decl, decl_attr); if (pedantic && type_quals && !DECL_IN_SYSTEM_HEADER (decl)) diff --git a/gcc/c-parser.c b/gcc/c-parser.c index bdf96ca6d92..29148266f9a 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -1707,6 +1707,8 @@ c_parser_enum_specifier (c_parser *parser) gcc_assert (c_parser_next_token_is_keyword (parser, RID_ENUM)); c_parser_consume_token (parser); attrs = c_parser_attributes (parser); + /* Set the location in case we create a decl now. */ + c_parser_set_source_position_from_token (c_parser_peek_token (parser)); if (c_parser_next_token_is (parser, CPP_NAME)) { ident = c_parser_peek_token (parser)->value; @@ -1728,6 +1730,7 @@ c_parser_enum_specifier (c_parser *parser) tree enum_value; tree enum_decl; bool seen_comma; + c_token *token; if (c_parser_next_token_is_not (parser, CPP_NAME)) { c_parser_error (parser, "expected identifier"); @@ -1735,7 +1738,10 @@ c_parser_enum_specifier (c_parser *parser) values = error_mark_node; break; } - enum_id = c_parser_peek_token (parser)->value; + token = c_parser_peek_token (parser); + enum_id = token->value; + /* Set the location in case we create a decl now. */ + c_parser_set_source_position_from_token (token); c_parser_consume_token (parser); if (c_parser_next_token_is (parser, CPP_EQ)) { @@ -1848,6 +1854,8 @@ c_parser_struct_or_union_specifier (c_parser *parser) } c_parser_consume_token (parser); attrs = c_parser_attributes (parser); + /* Set the location in case we create a decl now. */ + c_parser_set_source_position_from_token (c_parser_peek_token (parser)); if (c_parser_next_token_is (parser, CPP_NAME)) { ident = c_parser_peek_token (parser)->value; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index fd1f046ac21..e42f1ef4468 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,12 @@ +2007-11-01 Tom Tromey + + * gcc.dg/redecl-1.c: Update. + * gcc.dg/pr20368-3.c: Update. + * gcc.dg/inline-14.c: Update. + * gcc.dg/builtins-30.c: Update. + * gcc.dg/dremf-type-compat-4.c: Update. + * gcc.dg/pr20368-2.c: Update. + 2007-11-01 Jakub Jelinek PR rtl-optimization/33673 diff --git a/gcc/testsuite/gcc.dg/builtins-30.c b/gcc/testsuite/gcc.dg/builtins-30.c index f4e9859f98b..65a78fefe1d 100644 --- a/gcc/testsuite/gcc.dg/builtins-30.c +++ b/gcc/testsuite/gcc.dg/builtins-30.c @@ -6,22 +6,22 @@ extern double strtod (const char *, char **); /* A built-in function may be overridden by an old-style definition specifying too few arguments... */ -double cos () -{ /* { dg-warning "shadows a built-in" } */ +double cos () /* { dg-warning "shadows a built-in" } */ +{ /* { dg-warning "number of arguments doesn't match built-in prototype" "built-in" { target *-*-* } 10 } */ return strtod ("nan", 0); } /* the right number, but the wrong type, arguments... */ -double sin (foo) - int foo UNUSED; /* { dg-warning "shadows a built-in" } */ +double sin (foo) /* { dg-warning "shadows a built-in" } */ + int foo UNUSED; { /* { dg-warning "argument 'foo' doesn't match built-in prototype" } */ return strtod ("nan", 0); } /* or too many arguments. */ -long double cosl (foo, bar) - const char *foo UNUSED; /* { dg-warning "shadows a built-in" } */ +long double cosl (foo, bar) /* { dg-warning "shadows a built-in" } */ + const char *foo UNUSED; int bar UNUSED; { /* { dg-warning "number of arguments doesn't match built-in prototype" } */ /* { dg-warning "argument 'foo' doesn't match built-in prototype" "foo" { target *-*-* } 26 } */ diff --git a/gcc/testsuite/gcc.dg/dremf-type-compat-4.c b/gcc/testsuite/gcc.dg/dremf-type-compat-4.c index f815994539c..b3a2c5ad5d7 100644 --- a/gcc/testsuite/gcc.dg/dremf-type-compat-4.c +++ b/gcc/testsuite/gcc.dg/dremf-type-compat-4.c @@ -6,8 +6,8 @@ /* { dg-options "" } */ float -dremf(x, y) - float x, y; /* { dg-warning "conflicting types for built-in function 'dremf'" } */ +dremf(x, y) /* { dg-warning "conflicting types for built-in function 'dremf'" } */ + float x, y; { return x + y; } diff --git a/gcc/testsuite/gcc.dg/inline-14.c b/gcc/testsuite/gcc.dg/inline-14.c index 0987c7cde7b..cef62776fbb 100644 --- a/gcc/testsuite/gcc.dg/inline-14.c +++ b/gcc/testsuite/gcc.dg/inline-14.c @@ -7,8 +7,8 @@ extern inline int func1 (void) return 1; } -inline int func1 (void) -{ /* { dg-error "redefinition" } */ +inline int func1 (void) /* { dg-error "redefinition" } */ +{ return 1; } @@ -17,7 +17,7 @@ inline int func2 (void) return 2; } -inline int func2 (void) -{ /* { dg-error "redefinition" } */ +inline int func2 (void) /* { dg-error "redefinition" } */ +{ return 2; } diff --git a/gcc/testsuite/gcc.dg/pr20368-2.c b/gcc/testsuite/gcc.dg/pr20368-2.c index ca4a3e05a29..7faded6bd8c 100644 --- a/gcc/testsuite/gcc.dg/pr20368-2.c +++ b/gcc/testsuite/gcc.dg/pr20368-2.c @@ -6,7 +6,7 @@ extern __typeof (f) g; /* { dg-error "'f' undeclared here \\(not in a function\\)" } */ int -f (x) - float x; /* { dg-warning "no previous prototype for 'f'" } */ +f (x) /* { dg-warning "no previous prototype for 'f'" } */ + float x; { } diff --git a/gcc/testsuite/gcc.dg/pr20368-3.c b/gcc/testsuite/gcc.dg/pr20368-3.c index 9302077e89f..0d0ea6dfcc3 100644 --- a/gcc/testsuite/gcc.dg/pr20368-3.c +++ b/gcc/testsuite/gcc.dg/pr20368-3.c @@ -6,7 +6,7 @@ extern __typeof (f) g; /* { dg-error "'f' undeclared here \\(not in a function\\)" } */ int -f (x) - float x; /* { dg-warning "no previous declaration for 'f'" } */ +f (x) /* { dg-warning "no previous declaration for 'f'" } */ + float x; { } diff --git a/gcc/testsuite/gcc.dg/redecl-1.c b/gcc/testsuite/gcc.dg/redecl-1.c index cfabc8d25af..61d6e5b307a 100644 --- a/gcc/testsuite/gcc.dg/redecl-1.c +++ b/gcc/testsuite/gcc.dg/redecl-1.c @@ -76,8 +76,8 @@ void test5(void) /* Extern then static, both at file scope. */ extern int test6(int); /* { dg-error "previous" "" } */ -static int test6(int x) -{ return x; } /* { dg-error "follows non-static" } */ +static int test6(int x) /* { dg-error "follows non-static" } */ +{ return x; } /* Extern then static, extern at previous function scope. */ @@ -87,8 +87,8 @@ void prime7(void) extern int test7(int); /* { dg-error "previous" "" } */ } -static int test7(int x) -{ return x; } /* { dg-error "follows non-static" } */ +static int test7(int x) /* { dg-error "follows non-static" } */ +{ return x; } /* Implicit decl then static. */ @@ -98,5 +98,5 @@ void prime8(void) /* { dg-warning "implicit" "implicit" { target *-*-* } 97 } */ } -static int test8(int x) -{ return x; } /* { dg-error "follows non-static" } */ +static int test8(int x) /* { dg-error "follows non-static" } */ +{ return x; } -- 2.11.0