On Wed, 2017-04-26 at 14:02 +0200, Volker Reichelt wrote: > Hi, > > the following patch adds fix-it information for a diagnostic in the > C++ > parser: Use a scope operator instead of a single colon in a > nested-name-specifier. > > Bootstrapped and regtested on x86_64-pc-linux-gnu. > > OK for trunk?
OK for trunk (with my "diagnostic messages" maintainer hat on). Thanks Dave > Regards, > Volker > > > 2017-04-26 Volker Reichelt <v.reich...@netcologne.de> > > * parser.c (cp_parser_nested_name_specifier_opt): Add fix-it > information to diagnostic of invalid colon in nested-name > -specifier. > > Index: gcc/cp/parser.c > =================================================================== > --- gcc/cp/parser.c (revision 247254) > +++ gcc/cp/parser.c (working copy) > @@ -5931,8 +5931,11 @@ > && parser->colon_corrects_to_scope_p > && cp_lexer_peek_nth_token (parser->lexer, 3)->type == > CPP_NAME) > { > - error_at (token->location, > - "found %<:%> in nested-name-specifier, > expected %<::%>"); > + gcc_rich_location richloc (token->location); > + richloc.add_fixit_replace ("::"); > + error_at_rich_loc (&richloc, > + "found %<:%> in nested-name > -specifier, " > + "expected %<::%>"); > token->type = CPP_SCOPE; > } > > =================================================================== > > 2017-04-26 Volker Reichelt <v.reich...@netcologne.de> > > * g++.dg/diagnostic/nested-name-1.C: New test. > > Index: gcc/testsuite/g++.dg/diagnostic/nested-name-1.C > =================================================================== > --- gcc/testsuite/g++.dg/diagnostic/nested-name-1.C 2017-04-26 > +++ gcc/testsuite/g++.dg/diagnostic/nested-name-1.C 2017-04-26 > @@ -0,0 +1,13 @@ > +// { dg-options "-fdiagnostics-show-caret" } > + > +namespace N > +{ > + struct A {}; > +} > + > +N:A a; /* { dg-error "nested-name-specifier" } > + { dg-begin-multiline-output "" } > + N:A a; > + ^ > + :: > + { dg-end-multiline-output "" } */ > =================================================================== >