Commit b3e862e0 by Jason Merrill Committed by Jason Merrill

Give #include hints for <complex>.

	* name-lookup.c (get_std_name_hint): Add <complex>.
	* parser.c (cp_parser_diagnose_invalid_type_name): Call
	suggest_alternative_in_explicit_scope.
	(cp_parser_namespace_name): Likewise.

From-SVN: r255336
parent f2b8b8ad
2017-12-01 Jason Merrill <jason@redhat.com> 2017-12-01 Jason Merrill <jason@redhat.com>
Give #include hints for <complex>.
* name-lookup.c (get_std_name_hint): Add <complex>.
* parser.c (cp_parser_diagnose_invalid_type_name): Call
suggest_alternative_in_explicit_scope.
(cp_parser_namespace_name): Likewise.
PR c++/79228 - extensions hide C++14 complex literal operators PR c++/79228 - extensions hide C++14 complex literal operators
* parser.c (cp_parser_userdef_numeric_literal): Be helpful about * parser.c (cp_parser_userdef_numeric_literal): Be helpful about
'i' in C++14 and up. 'i' in C++14 and up.
......
...@@ -5414,6 +5414,9 @@ get_std_name_hint (const char *name) ...@@ -5414,6 +5414,9 @@ get_std_name_hint (const char *name)
static const std_name_hint hints[] = { static const std_name_hint hints[] = {
/* <array>. */ /* <array>. */
{"array", "<array>"}, // C++11 {"array", "<array>"}, // C++11
/* <complex>. */
{"complex", "<complex>"},
{"complex_literals", "<complex>"},
/* <deque>. */ /* <deque>. */
{"deque", "<deque>"}, {"deque", "<deque>"},
/* <forward_list>. */ /* <forward_list>. */
......
...@@ -3365,6 +3365,9 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree id, ...@@ -3365,6 +3365,9 @@ cp_parser_diagnose_invalid_type_name (cp_parser *parser, tree id,
id, parser->scope); id, parser->scope);
if (DECL_P (decl)) if (DECL_P (decl))
inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl); inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
else if (decl == error_mark_node)
suggest_alternative_in_explicit_scope (location, id,
parser->scope);
} }
else if (CLASS_TYPE_P (parser->scope) else if (CLASS_TYPE_P (parser->scope)
&& constructor_name_p (id, parser->scope)) && constructor_name_p (id, parser->scope))
...@@ -18408,7 +18411,13 @@ cp_parser_namespace_name (cp_parser* parser) ...@@ -18408,7 +18411,13 @@ cp_parser_namespace_name (cp_parser* parser)
|| TREE_CODE (namespace_decl) != NAMESPACE_DECL) || TREE_CODE (namespace_decl) != NAMESPACE_DECL)
{ {
if (!cp_parser_uncommitted_to_tentative_parse_p (parser)) if (!cp_parser_uncommitted_to_tentative_parse_p (parser))
error_at (token->location, "%qD is not a namespace-name", identifier); {
error_at (token->location, "%qD is not a namespace-name", identifier);
if (namespace_decl == error_mark_node
&& parser->scope && TREE_CODE (parser->scope) == NAMESPACE_DECL)
suggest_alternative_in_explicit_scope (token->location, identifier,
parser->scope);
}
cp_parser_error (parser, "expected namespace-name"); cp_parser_error (parser, "expected namespace-name");
namespace_decl = error_mark_node; namespace_decl = error_mark_node;
} }
std::complex<int> c; // { dg-error "" }
// { dg-message "#include <complex>" "" { target *-*-* } .-1 }
using namespace std::complex_literals; // { dg-error "" }
// { dg-message "#include <complex>" "" { target *-*-* } .-1 }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment