Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk?

-- >8 --
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.
---
 gcc/cp/error.cc                             | 15 +++++++++++++++
 gcc/testsuite/g++.dg/diagnostic/arg-pack1.C | 10 ++++++++++
 2 files changed, 25 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/diagnostic/arg-pack1.C

diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 4736f4875ea..8c0644fba7e 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 00000000000..643fc7f665e
--- /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} }
+}

base-commit: 7d6dc2130970ccf6555d4e9f977515c6c20f7d2f
-- 
2.47.1

Reply via email to