From: Volker Reichelt Date: Wed, 26 Apr 2017 16:57:25 +0000 (+0000) Subject: parser.c (cp_parser_nested_name_specifier_opt): Add fix-it information to diagnostic... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a480422d0ad67c0ced6b1a3a21c228277381b053;p=gcc.git parser.c (cp_parser_nested_name_specifier_opt): Add fix-it information to diagnostic of invalid colon in nested-name-specifier. * parser.c (cp_parser_nested_name_specifier_opt): Add fix-it information to diagnostic of invalid colon in nested-name-specifier. * g++.dg/diagnostic/nested-name-1.C: New test. From-SVN: r247282 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1a9ca1942b8..40d2cc2ac73 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2017-04-26 Volker Reichelt + + * parser.c (cp_parser_nested_name_specifier_opt): Add fix-it + information to diagnostic of invalid colon in nested-name-specifier. + 2017-04-25 Volker Reichelt * parser.c (cp_parser_elaborated_type_specifier): Add fix-it to diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 4714bc6cd89..640a601bafa 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -5931,8 +5931,11 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, && 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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 696eb272d42..718de7eae83 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-04-26 Volker Reichelt + + * g++.dg/diagnostic/nested-name-1.C: New test. + 2017-04-26 Martin Liska * gcc.dg/guality/guality.h: Add prefix to test verification. diff --git a/gcc/testsuite/g++.dg/diagnostic/nested-name-1.C b/gcc/testsuite/g++.dg/diagnostic/nested-name-1.C new file mode 100644 index 00000000000..a02761cef7b --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/nested-name-1.C @@ -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 "" } */