This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH for c++/55241 (wrong dumping of sizeof...)
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 16 Mar 2013 14:51:32 -0400
- Subject: C++ PATCH for c++/55241 (wrong dumping of sizeof...)
The diagnostic code didn't understand sizeof...
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 824613a2b13236e896abb202c225f2e3628616c8
Author: Jason Merrill <jason@redhat.com>
Date: Wed Feb 13 17:19:20 2013 -0500
PR c++/55241
* error.c (dump_expr) [SIZEOF_EXPR]: Print sizeof... properly.
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index c2bf54d..c3dce1d 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -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
index 0000000..69f1f98
--- /dev/null
+++ b/gcc/testsuite/g++.dg/diagnostic/variadic1.C
@@ -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" }
+};