Commit 8d25372f by Marek Polacek Committed by Marek Polacek

pt.c (convert_template_argument): Add a diagnostic for the [temp.arg]/2 ambiguity case.

	* pt.c (convert_template_argument): Add a diagnostic for the
	[temp.arg]/2 ambiguity case.

	* g++.dg/cpp2a/nontype-class17.C: New test.

From-SVN: r271431
parent 21582672
2019-05-20 Marek Polacek <polacek@redhat.com>
* pt.c (convert_template_argument): Add a diagnostic for the
[temp.arg]/2 ambiguity case.
2019-05-20 Paolo Carlini <paolo.carlini@oracle.com> 2019-05-20 Paolo Carlini <paolo.carlini@oracle.com>
* cp-tree.h: Remove remnants of CONV_NONCONVERTING. * cp-tree.h: Remove remnants of CONV_NONCONVERTING.
......
...@@ -7963,10 +7963,22 @@ convert_template_argument (tree parm, ...@@ -7963,10 +7963,22 @@ convert_template_argument (tree parm,
"parameter list for %qD", "parameter list for %qD",
i + 1, in_decl); i + 1, in_decl);
if (is_type) if (is_type)
inform (input_location, {
" expected a constant of type %qT, got %qT", /* The template argument is a type, but we're expecting
TREE_TYPE (parm), an expression. */
(DECL_P (arg) ? DECL_NAME (arg) : orig_arg)); inform (input_location,
" expected a constant of type %qT, got %qT",
TREE_TYPE (parm),
(DECL_P (arg) ? DECL_NAME (arg) : orig_arg));
/* [temp.arg]/2: "In a template-argument, an ambiguity
between a type-id and an expression is resolved to a
type-id, regardless of the form of the corresponding
template-parameter." So give the user a clue. */
if (TREE_CODE (arg) == FUNCTION_TYPE)
inform (input_location, " ambiguous template argument "
"for non-type template parameter is treated as "
"function type");
}
else if (requires_tmpl_type) else if (requires_tmpl_type)
inform (input_location, inform (input_location,
" expected a class template, got %qE", orig_arg); " expected a class template, got %qE", orig_arg);
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* g++.dg/ext/utf8-2.C: Accept both "char" and "char8_t" in aka. * g++.dg/ext/utf8-2.C: Accept both "char" and "char8_t" in aka.
* g++.dg/cpp2a/nontype-class17.C: New test.
2019-05-20 Jeff Law <law@redhat.com> 2019-05-20 Jeff Law <law@redhat.com>
* gcc.dg/Wtype-limits-Wextra.c: Adjust expected output after * gcc.dg/Wtype-limits-Wextra.c: Adjust expected output after
......
// { dg-do compile { target c++2a } }
template<auto>
struct S { };
struct R { };
void
g (void)
{
S<R()> s; // { dg-error "mismatch" }
// { dg-message "treated as function" "note" { target *-*-* } .-1 }
S<R{}> s2;
S<int()> s3; // { dg-error "mismatch" }
// { dg-message "treated as function" "note" { target *-*-* } .-1 }
S<int{}> s4;
}
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