+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>
* cp-tree.h: Remove remnants of CONV_NONCONVERTING.
"parameter list for %qD",
i + 1, in_decl);
if (is_type)
- inform (input_location,
- " expected a constant of type %qT, got %qT",
- TREE_TYPE (parm),
- (DECL_P (arg) ? DECL_NAME (arg) : orig_arg));
+ {
+ /* The template argument is a type, but we're expecting
+ an expression. */
+ 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)
inform (input_location,
" expected a class template, got %qE", orig_arg);
* 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>
* gcc.dg/Wtype-limits-Wextra.c: Adjust expected output after
--- /dev/null
+// { 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;
+}