re PR c++/55241 ([C++11] diagnostics show sizeof...(T) as sizeof(T...))
authorJason Merrill <jason@redhat.com>
Sun, 17 Mar 2013 02:34:31 +0000 (22:34 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sun, 17 Mar 2013 02:34:31 +0000 (22:34 -0400)
PR c++/55241
* error.c (dump_expr) [SIZEOF_EXPR]: Print sizeof... properly.

From-SVN: r196726

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/testsuite/g++.dg/diagnostic/variadic1.C [new file with mode: 0644]

index 14bab43a32bd4f3c3bd58ff8bc33e0c367e8644d..5b278201f7b6234d419bd15a2d2bc2db7ff59623 100644 (file)
@@ -1,5 +1,8 @@
 2013-03-16  Jason Merrill  <jason@redhat.com>
 
+       PR c++/55241
+       * error.c (dump_expr) [SIZEOF_EXPR]: Print sizeof... properly.
+
        * parser.c (lookup_literal_operator): Correct parm/arg naming
        mixup.
 
index c2bf54dcb2caa5af739d70fa1bfd9df084235cdc..c3dce1dd5b3f69a44fbc271f9eeaec8231d06319 100644 (file)
@@ -1783,6 +1783,8 @@ resolve_virtual_fun_from_obj_type_ref (tree ref)
 static void
 dump_expr (tree t, int flags)
 {
+  tree op;
+
   if (t == 0)
     return;
 
@@ -2316,14 +2318,20 @@ dump_expr (tree t, int flags)
          gcc_assert (TREE_CODE (t) == ALIGNOF_EXPR);
          pp_cxx_ws_string (cxx_pp, "__alignof__");
        }
+      op = TREE_OPERAND (t, 0);
+      if (PACK_EXPANSION_P (op))
+       {
+         pp_string (cxx_pp, "...");
+         op = PACK_EXPANSION_PATTERN (op);
+       }
       pp_cxx_whitespace (cxx_pp);
       pp_cxx_left_paren (cxx_pp);
       if (TREE_CODE (t) == SIZEOF_EXPR && SIZEOF_EXPR_TYPE_P (t))
-       dump_type (TREE_TYPE (TREE_OPERAND (t, 0)), flags);
+       dump_type (TREE_TYPE (op), flags);
       else if (TYPE_P (TREE_OPERAND (t, 0)))
-       dump_type (TREE_OPERAND (t, 0), flags);
+       dump_type (op, flags);
       else
-       dump_expr (TREE_OPERAND (t, 0), flags);
+       dump_expr (op, flags);
       pp_cxx_right_paren (cxx_pp);
       break;
 
diff --git a/gcc/testsuite/g++.dg/diagnostic/variadic1.C b/gcc/testsuite/g++.dg/diagnostic/variadic1.C
new file mode 100644 (file)
index 0000000..69f1f98
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/55241
+// { dg-do compile { target c++11 } }
+
+template<int N> struct B { };
+template<typename... T> struct A
+{
+  B<sizeof...(T)> f();         // { dg-error "sizeof\\.\\.\\." }
+  B<42> f();                   // { dg-error "cannot be overloaded" }
+};