diff options
author | Marek Polacek <polacek@redhat.com> | 2024-12-17 13:44:22 -0500 |
---|---|---|
committer | Marek Polacek <polacek@redhat.com> | 2024-12-17 14:27:49 -0500 |
commit | 91733c095ee714c0b384153754c6327d5506cd19 (patch) | |
tree | fc061fb5e4973d093a1dd747cdd443ccfdcd15b5 /gcc | |
parent | 7d6dc2130970ccf6555d4e9f977515c6c20f7d2f (diff) | |
download | gcc-91733c095ee714c0b384153754c6327d5506cd19.zip gcc-91733c095ee714c0b384153754c6327d5506cd19.tar.gz gcc-91733c095ee714c0b384153754c6327d5506cd19.tar.bz2 |
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<expression error>>
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) <case NONTYPE_ARGUMENT_PACK>: New case.
gcc/testsuite/ChangeLog:
* g++.dg/diagnostic/arg-pack1.C: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/error.cc | 15 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/diagnostic/arg-pack1.C | 10 |
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc index 4736f48..8c0644f 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 0000000..643fc7f --- /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<int... Ns> +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} } +} |