aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/error.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2024-01-17 17:29:33 -0500
committerJason Merrill <jason@redhat.com>2024-01-19 13:35:04 -0500
commitf1e5bf0d83ee4da81b6317c6d7f1278fe7eaa5a0 (patch)
treeaa8ae41f486fca7101c25e70c7eb3aac1c88190f /gcc/cp/error.cc
parente04376b336502016456eaf4e90c3ea792c77c8df (diff)
downloadgcc-f1e5bf0d83ee4da81b6317c6d7f1278fe7eaa5a0.zip
gcc-f1e5bf0d83ee4da81b6317c6d7f1278fe7eaa5a0.tar.gz
gcc-f1e5bf0d83ee4da81b6317c6d7f1278fe7eaa5a0.tar.bz2
c++: alias template argument conversion [PR112632]
We've had a problem with lost conversions to template parameter types for a while now; looking at this PR, it occurred to me that the problem is really with alias (and concept) templates, since we do substitution of dependent arguments into them in a way that we don't for other templates. And fixing that specific problem is a lot simpler than adding IMPLICIT_CONV_EXPR around all dependent template arguments the way I gave up on for 111357. The other part of the fix was changing tsubst_expr to actually call convert_nontype_argument instead of assuming it will eventually happen. I waffled about stripping the forced conversion when !force_conv vs. skipping them in iterative_hash_template_arg and template_args_equal (like we already do for some other conversions) and decided to go with the former, but that isn't a strong preference if it turns out to be somehow problematic. PR c++/112632 PR c++/112594 PR c++/111357 PR c++/104594 PR c++/67898 gcc/cp/ChangeLog: * cp-tree.h (IMPLICIT_CONV_EXPR_FORCED): New. * pt.cc (expand_integer_pack): Remove 111357 workaround. (maybe_convert_nontype_argument): Add force parm. (convert_template_argument): Handle alias template args specially. (tsubst_expr): Don't ignore IMPLICIT_CONV_EXPR_NONTYPE_ARG. * error.cc (dump_expr) [CASE_CONVERT]: Handle null optype. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-nontype1.C: New test. * g++.dg/cpp2a/concepts-narrowing1.C: New test. * g++.dg/cpp2a/nontype-class63.C: New test. * g++.dg/cpp2a/nontype-class63a.C: New test.
Diffstat (limited to 'gcc/cp/error.cc')
-rw-r--r--gcc/cp/error.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 52e24fb..d3fcac7 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -2673,6 +2673,8 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
tree ttype = TREE_TYPE (t);
tree optype = TREE_TYPE (op);
+ if (!optype)
+ optype = unknown_type_node;
if (TREE_CODE (ttype) != TREE_CODE (optype)
&& INDIRECT_TYPE_P (ttype)
@@ -2691,7 +2693,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
else
dump_unary_op (pp, "&", t, flags);
}
- else if (!same_type_p (TREE_TYPE (op), TREE_TYPE (t)))
+ else if (!same_type_p (optype, ttype))
{
/* It is a cast, but we cannot tell whether it is a
reinterpret or static cast. Use the C style notation. */