From: Marek Polacek Date: Tue, 17 Dec 2024 18:44:22 +0000 (-0500) Subject: c++: print NONTYPE_ARGUMENT_PACK [PR118073] X-Git-Tag: basepoints/gcc-16~3240 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91733c095ee714c0b384153754c6327d5506cd19;p=thirdparty%2Fgcc.git c++: print NONTYPE_ARGUMENT_PACK [PR118073] This PR points out that we're not pretty-printing NONTYPE_ARGUMENT_PACK so the compiler emits the ugly: 'nontype_argument_pack' not supported by dump_expr> Fixed thus. I've wrapped the elements of the pack in { } because that's what cxx_pretty_printer::expression does. PR c++/118073 gcc/cp/ChangeLog: * error.cc (dump_expr) : New case. gcc/testsuite/ChangeLog: * g++.dg/diagnostic/arg-pack1.C: New test. --- diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 4736f4875eaf..8c0644fba7ea 100644 --- a/gcc/cp/error.cc +++ b/gcc/cp/error.cc @@ -3173,6 +3173,21 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) dump_expr_list (pp, t, flags); break; + case NONTYPE_ARGUMENT_PACK: + { + tree args = ARGUMENT_PACK_ARGS (t); + int len = TREE_VEC_LENGTH (args); + pp_cxx_left_brace (pp); + for (int i = 0; i < len; ++i) + { + if (i > 0) + pp_separate_with_comma (pp); + dump_expr (pp, TREE_VEC_ELT (args, i), flags); + } + pp_cxx_right_brace (pp); + break; + } + /* This list is incomplete, but should suffice for now. It is very important that `sorry' does not call `report_error_function'. That could cause an infinite loop. */ diff --git a/gcc/testsuite/g++.dg/diagnostic/arg-pack1.C b/gcc/testsuite/g++.dg/diagnostic/arg-pack1.C new file mode 100644 index 000000000000..643fc7f665e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/diagnostic/arg-pack1.C @@ -0,0 +1,10 @@ +// PR c++/118073 +// { dg-do compile { target c++11 } } + +template +struct index_sequence {}; + +void foo() +{ + index_sequence<5> bar = index_sequence<1>(); // { dg-error {conversion from 'index_sequence<\{1\}>' to non-scalar type 'index_sequence<\{5\}>' requested} } +}