public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/55241 (wrong dumping of sizeof...)
@ 2013-03-16 18:51 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2013-03-16 18:51 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 96 bytes --]

The diagnostic code didn't understand sizeof...

Tested x86_64-pc-linux-gnu, applying to trunk.

[-- Attachment #2: 55241.patch --]
[-- Type: text/x-patch, Size: 1734 bytes --]

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" }
+};

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-03-16 18:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-16 18:51 C++ PATCH for c++/55241 (wrong dumping of sizeof...) Jason Merrill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).