This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c-parser.c replace error() by error_at()


On Wed, Feb 19, 2014 at 9:41 PM, Marek Polacek <polacek@redhat.com> wrote:
> On Wed, Feb 19, 2014 at 08:45:04PM +0530, Prathamesh Kulkarni wrote:
>> Index: gcc/c/c-parser.c
>> ===================================================================
>> --- gcc/c/c-parser.c (revision 207700)
>> +++ gcc/c/c-parser.c (working copy)
>> @@ -2223,7 +2223,7 @@ c_parser_declspecs (c_parser *parser, st
>>    attrs_ok = true;
>>    if (kind == C_ID_ID)
>>      {
>> -      error ("unknown type name %qE", value);
>> +      error_at (loc, "unknown type name %qE", value);
>>        t.kind = ctsk_typedef;
>>        t.spec = error_mark_node;
>>      }
>> @@ -3608,7 +3608,7 @@ c_parser_parameter_declaration (c_parser
>>        c_parser_set_source_position_from_token (token);
>>        if (c_parser_next_tokens_start_typename (parser, cla_prefer_type))
>>   {
>> -  error ("unknown type name %qE", token->value);
>> +  error_at (token->location, "unknown type name %qE", token->value);
>>    parser->error = true;
>>   }
>>        /* ??? In some Objective-C cases '...' isn't applicable so there
>
> BTW, your MUA eats tabs, so the patch can't be applied (common gmail
> problem).
I have sent it attached this time.
>
>> Index: gcc/testsuite/gcc.dg/decl-10.c
>> ===================================================================
>> --- gcc/testsuite/gcc.dg/decl-10.c (revision 0)
>> +++ gcc/testsuite/gcc.dg/decl-10.c (working copy)
>> @@ -0,0 +1,13 @@
>> +/* { dg-do compile } */
>> +
>> +void
>> +f4(const foo x) /* { dg-error "unknown type name" } */
>> +{}
>> +
>> +void
>> +f5(foo x, int i) /* { dg-error "unknown type name" } */
>> +{}
>> +
>> +void
>> +f6(char c, foo x, ...) /* { dg-error "unknown type name" } */
>> +{}
>
> Since we're testing the column numbers here, those dg-errors should
> test that.  So please adjust them:
> /* { dg-error "10:unknown type name" } */
> /* { dg-error "4:unknown type name" } */
> /* { dg-error "12:unknown type name" } */
Added.
>
> Thanks.
>
[gcc/c]
* c-parser.c (c_parser_declspecs): Replace call to error by error_at.
* c-parser.c (c_parser_parameter_declaration): Likewise.

[gcc/testsuite]
* gcc.dg/decl-10.c: New test case.

>         Marek
Index: gcc/c/c-parser.c
===================================================================
--- gcc/c/c-parser.c	(revision 207700)
+++ gcc/c/c-parser.c	(working copy)
@@ -2223,7 +2223,7 @@ c_parser_declspecs (c_parser *parser, st
 	  attrs_ok = true;
 	  if (kind == C_ID_ID)
 	    {
-	      error ("unknown type name %qE", value);
+	      error_at (loc, "unknown type name %qE", value);
 	      t.kind = ctsk_typedef;
 	      t.spec = error_mark_node;
 	    }
@@ -3608,7 +3608,7 @@ c_parser_parameter_declaration (c_parser
       c_parser_set_source_position_from_token (token);
       if (c_parser_next_tokens_start_typename (parser, cla_prefer_type))
 	{
-	  error ("unknown type name %qE", token->value);
+	  error_at (token->location, "unknown type name %qE", token->value);
 	  parser->error = true;
 	}
       /* ??? In some Objective-C cases '...' isn't applicable so there
Index: gcc/testsuite/gcc.dg/decl-10.c
===================================================================
--- gcc/testsuite/gcc.dg/decl-10.c	(revision 0)
+++ gcc/testsuite/gcc.dg/decl-10.c	(working copy)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+
+void
+f4(const foo x) /* { dg-error "10:unknown type name" } */
+{}
+
+void
+f5(foo x, int i) /* { dg-error "4:unknown type name" } */
+{}
+
+void
+f6(char c, foo x, ...) /* { dg-error "12:unknown type name" } */
+{}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]