On 6/12/19 5:36 PM, Paolo Carlini wrote:
Hi,

On 12/06/19 22:24, Jason Merrill wrote:
On 6/6/19 9:00 AM, Paolo Carlini wrote:
Hi,

only minor functional changes here - more precise locations for two error messages  - but I think it's a step in the right direction: it moves the declaration of id_loc way up, near typespec_loc and as such id_loc is immediately used. Then its value is updated upon the loop over declarator in the middle of the function and used again in the final part of the function. That also "frees" the simple name loc for other local uses, allows to simplify those checks changed rather recently over (name && declarator). and (unqualified_id && declarator). Tested x86_64-linux.

Mostly OK, except:

   if (declspecs->multiple_types_p)
     {
-      error ("two or more data types in declaration of %qs", name);
+      error_at (id_loc, "two or more data types in declaration of %qs", name);
       return error_mark_node;
     }

declspecs->locations[ds_type_spec]?

   if (declspecs->conflicting_specifiers_p)
     {
-      error ("conflicting specifiers in declaration of %qs", name);
+      error_at (id_loc, "conflicting specifiers in declaration of %qs", name);
       return error_mark_node;
     }

ds_storage_class/ds_typedef?

Ok.

Ideally, it would be nice to have available locations for the two leftmost data types and, for the second error, the locations of conflicting storage classes (eg, static and register). Other compilers then point to the second one, where the issue shows up. I think we already briefly discussed that kind of logic in the past, but in those cases we had available all the locations we needed and we ended up using gcc_rich_location and add_range, etc..

Anyway, we can certainly use typespec_loc and the minimum of ds_storage_class and ds_typedef, respectively, like in the below, which passes testing.

Thanks! Paolo.

OK.

Jason

Reply via email to