Commit 5af28c74 by Tom Tromey Committed by Tom Tromey

c-decl.c (grokdeclarator): Set decl source locations.

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.

From-SVN: r129822
parent 18aa09d1
2007-11-01 Tom Tromey <tromey@redhat.com>
* 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 <tromey@redhat.com>
* print-tree.c (print_node): Print column number.
2007-11-01 Jakub Jelinek <jakub@redhat.com>
......@@ -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))
......
......@@ -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;
......
2007-11-01 Tom Tromey <tromey@redhat.com>
* 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 <jakub@redhat.com>
PR rtl-optimization/33673
......@@ -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 } */
......
......@@ -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;
}
......@@ -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;
}
......@@ -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;
{
}
......@@ -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;
{
}
......@@ -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; }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment