c-decl.c (grokdeclarator): Set decl source locations.
authorTom Tromey <tromey@redhat.com>
Thu, 1 Nov 2007 15:31:12 +0000 (15:31 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Thu, 1 Nov 2007 15:31:12 +0000 (15:31 +0000)
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

gcc/ChangeLog
gcc/c-decl.c
gcc/c-parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtins-30.c
gcc/testsuite/gcc.dg/dremf-type-compat-4.c
gcc/testsuite/gcc.dg/inline-14.c
gcc/testsuite/gcc.dg/pr20368-2.c
gcc/testsuite/gcc.dg/pr20368-3.c
gcc/testsuite/gcc.dg/redecl-1.c

index 68ec0edc3b2fbc9f54020abbf96329e106b6eb93..7363e52993695532043c18e3baec5e2907062ec9 100644 (file)
@@ -1,3 +1,9 @@
+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.
index 1152253e2e2d0fbc0679ec0d181a596cf03174ea..5ddbcc0772a6338a5e4b7c6791f8136a2e750dc1 100644 (file)
@@ -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))
index bdf96ca6d920781e5f99adc33cacc342cafaecec..29148266f9a1db26b5c4f6421976d70be9238832 100644 (file)
@@ -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;
index fd1f046ac218d218f810ce9351ad6fd44e5d90fb..e42f1ef44682d117725e2b65cd868b067d40f464 100644 (file)
@@ -1,3 +1,12 @@
+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
index f4e9859f98b48f3d9725f49bf920697781cc871f..65a78fefe1d9af12523c6b145289e4da73355b60 100644 (file)
@@ -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 } */
index f815994539c57e08abc05ae385a98cbfd9ebb221..b3a2c5ad5d7ba65e283b0f658b2fca497023f337 100644 (file)
@@ -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;
 }
index 0987c7cde7b3f080c3cb366a8050e8847665fb4b..cef62776fbbcf540b65deaa6e628768779d0eaee 100644 (file)
@@ -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;
 }
index ca4a3e05a29a0d3c3a4e19646cc060355e047701..7faded6bd8cf823705929b9e833b1b637796057a 100644 (file)
@@ -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;
 {
 }
index 9302077e89f853bd8c861416de46d246e2418afb..0d0ea6dfcc33294eebad7069b3ca60e5e0cec08b 100644 (file)
@@ -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;
 {
 }
index cfabc8d25af05d2d95f134c954b3e910f019d78f..61d6e5b307a2812e094f0f6cd26841aa452af515 100644 (file)
@@ -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; }