This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] C++: fix fix-it hints for misspellings within explicit namespaces (v2)
On Thu, Jan 19, 2017 at 3:56 PM, David Malcolm <dmalcolm@redhat.com> wrote:
> On Thu, 2017-01-19 at 13:15 -0500, Jason Merrill wrote:
>> On Wed, Jan 18, 2017 at 5:29 PM, David Malcolm <dmalcolm@redhat.com>
>> wrote:
>> > Here's a version of the patch which simply tweaks
>> > cp_parser_primary_expression's call to finish_id_expression so that
>> > it passes the location of the id_expression, rather than that of
>> > id_expr_token.
>> >
>> > The id_expression in question came from cp_parser_id_expression,
>> > whereas the id_expr_token is the first token within the id
>> > -expression.
>> >
>> > The location passed here to finish_id_expression only affects:
>> > the location used for name-lookup errors, and for the resulting
>> > decl cp_expr. Given that the following code immediately does this:
>> > decl.set_location (id_expr_token->location);
>>
>> What happens if we use id_expression.get_location() here, too?
>>
>> OK.
>
> With that other change it bootstraps but introduces some regressions:
>
> PASS -> FAIL : g++.dg/cpp0x/pr51420.C -std=c++11 (test for errors, line 6)
> PASS -> FAIL : g++.dg/cpp0x/pr51420.C -std=c++11 (test for excess errors)
> PASS -> FAIL : g++.dg/cpp0x/pr51420.C -std=c++14 (test for errors, line 6)
> PASS -> FAIL : g++.dg/cpp0x/pr51420.C -std=c++14 (test for excess errors)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++11 (test for errors, line 11)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++11 (test for errors, line 14)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++11 (test for errors, line 5)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++11 (test for errors, line 8)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++11 (test for excess errors)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++14 (test for errors, line 11)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++14 (test for errors, line 14)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++14 (test for errors, line 5)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++14 (test for errors, line 8)
> PASS -> FAIL : g++.dg/cpp0x/udlit-declare-neg.C -std=c++14 (test for excess errors)
>
> It would change:
>
> g++.dg/cpp0x/pr51420.C: In function ‘void foo()’:
> g++.dg/cpp0x/pr51420.C:6:13: error: ‘operator""_F’ was not declared in this scope
> float x = operator"" _F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" }
> ^~~~~~~~
> g++.dg/cpp0x/pr51420.C:6:13: note: suggested alternative: ‘operator new’
> float x = operator"" _F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" }
> ^~~~~~~~
> operator new
>
> to:
>
> g++.dg/cpp0x/pr51420.C: In function ‘void foo()’:
> g++.dg/cpp0x/pr51420.C:6:27: error: ‘operator""_F’ was not declared in this scope
> float x = operator"" _F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" }
> ^
>
> and would change:
>
> g++.dg/cpp0x/udlit-declare-neg.C:5:9: error: ‘operator""_Bar’ was not declared in this scope
> int i = operator"" _Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
> ^~~~~~~~
> g++.dg/cpp0x/udlit-declare-neg.C:5:9: note: suggested alternative: ‘operator new’
> int i = operator"" _Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
> ^~~~~~~~
> operator new
>
> to:
>
> g++.dg/cpp0x/udlit-declare-neg.C:5:28: error: ‘operator""_Bar’ was not declared in this scope
> int i = operator"" _Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
> ^
>
> (DejaGnu picked up on this via the changing column numbers, but it
> didn't detect the missing "suggested alternative").
>
>
> With the patch I posted as-is, we get:
>
> g++.dg/cpp0x/pr51420.C:6:13: error: ‘operator""_F’ was not declared in this scope
> float x = operator"" _F(); // { dg-error "13:'operator\"\"_F' was not declared in this scope" }
> ^~~~~~~~
>
> and:
>
> g++.dg/cpp0x/udlit-declare-neg.C:5:9: error: ‘operator""_Bar’ was not declared in this scope
> int i = operator"" _Bar('x'); // { dg-error "9:'operator\"\"_Bar' was not declared in this scope" }
> ^~~~~~~~
>
> i.e. the same locations as the status quo, but dropping the suggested
> "operator new" hint.
>
>
> Is the patch still OK as-is?
Yes.
Jason