c++: Don't show constructor internal name in error message [PR105483]
We mention 'X::__ct' instead of 'X::X' in the "names the constructor, not the type" error for this invalid code: === cut here === struct X {}; void g () { X::X x; } === cut here === The problem is that we use %<%T::%D%> to build the error message, while %qE does exactly what we need since we have DECL_CONSTRUCTOR_P. This is what this patch does. It also skips until the end of the statement and returns error_mark_node for this and the preceding if block, to avoid emitting extra (useless) errors. PR c++/105483 gcc/cp/ChangeLog: * parser.cc (cp_parser_expression_statement): Use %qE instead of incorrect %<%T::%D%>. Skip to end of statement and return error_mark_node in case of error. gcc/testsuite/ChangeLog: * g++.dg/parse/error36.C: Adjust test expectation. * g++.dg/tc1/dr147.C: Likewise. * g++.old-deja/g++.other/typename1.C: Likewise. * g++.dg/diagnostic/pr105483.C: New test.
Showing
- gcc/cp/parser.cc 9 additions, 5 deletionsgcc/cp/parser.cc
- gcc/testsuite/g++.dg/diagnostic/pr105483.C 7 additions, 0 deletionsgcc/testsuite/g++.dg/diagnostic/pr105483.C
- gcc/testsuite/g++.dg/parse/error36.C 2 additions, 2 deletionsgcc/testsuite/g++.dg/parse/error36.C
- gcc/testsuite/g++.dg/tc1/dr147.C 1 addition, 1 deletiongcc/testsuite/g++.dg/tc1/dr147.C
- gcc/testsuite/g++.old-deja/g++.other/typename1.C 1 addition, 1 deletiongcc/testsuite/g++.old-deja/g++.other/typename1.C
Loading
Please register or sign in to comment