diff mbox

[C++] PR 45487

Message ID 4E81063A.5070702@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Sept. 26, 2011, 11:09 p.m. UTC
Hi,

the below implements what submitter requested - ie, separate bindings 
with semicolons instead of commas, already used in many other places. 
Seems a pretty straightforward change to me. Tested x86_64-linux.

Ok for mainline?

Thanks,
Paolo.

/////////////////////
/cp
2011-09-26  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/45487
	* error.c (dump_template_bindings): Separate bindings with semicolons
	instead of commas.

/testsuite
2011-09-26  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/45487
	* g++.dg/diagnostic/bindings1.C: New.
	* g++.old-deja/g++.pt/memtemp77.C: Adjust.

Comments

Jason Merrill Sept. 27, 2011, 12:19 a.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: testsuite/g++.old-deja/g++.pt/memtemp77.C
===================================================================
--- testsuite/g++.old-deja/g++.pt/memtemp77.C	(revision 179215)
+++ testsuite/g++.old-deja/g++.pt/memtemp77.C	(working copy)
@@ -19,7 +19,7 @@  const char* S3<char>::h(int) { return __PRETTY_FUN
 int main()
 {
   if (strcmp (S3<double>::h(7), 
-	      "static const char* S3<T>::h(U) [with U = int, T = double]") == 0)
+	      "static const char* S3<T>::h(U) [with U = int; T = double]") == 0)
     return 0;
   else 
     return 1;
Index: testsuite/g++.dg/diagnostic/bindings1.C
===================================================================
--- testsuite/g++.dg/diagnostic/bindings1.C	(revision 0)
+++ testsuite/g++.dg/diagnostic/bindings1.C	(revision 0)
@@ -0,0 +1,18 @@ 
+// PR c++/45487
+// { dg-do run  }
+
+extern "C" int strcmp(const char*, const char*);
+
+template <typename T>
+const char* foo(T, typename T::type c) { return __PRETTY_FUNCTION__; }
+
+struct x {typedef int type;};
+
+int main()
+{
+  if (strcmp (foo(x(), 3), "const char* foo(T, typename T::type) "
+	      "[with T = x; typename T::type = int]") == 0)
+    return 0;
+  else 
+    return 1;
+}
Index: cp/error.c
===================================================================
--- cp/error.c	(revision 179215)
+++ cp/error.c	(working copy)
@@ -36,6 +36,7 @@  along with GCC; see the file COPYING3.  If not see
 #include "c-family/c-objc.h"
 
 #define pp_separate_with_comma(PP) pp_cxx_separate_with (PP, ',')
+#define pp_separate_with_semicolon(PP) pp_cxx_separate_with (PP, ';')
 
 /* The global buffer where we dump everything.  It is there only for
    transitional purpose.  It is expected, in the near future, to be
@@ -259,7 +260,7 @@  dump_template_parameter (tree parm, int flags)
 static void
 dump_template_bindings (tree parms, tree args, VEC(tree,gc)* typenames)
 {
-  int need_comma = 0;
+  bool need_semicolon = false;
   int i;
   tree t;
 
@@ -283,8 +284,8 @@  dump_template_bindings (tree parms, tree args, VEC
 	  if (lvl_args && NUM_TMPL_ARGS (lvl_args) > arg_idx)
 	    arg = TREE_VEC_ELT (lvl_args, arg_idx);
 
-	  if (need_comma)
-	    pp_separate_with_comma (cxx_pp);
+	  if (need_semicolon)
+	    pp_separate_with_semicolon (cxx_pp);
 	  dump_template_parameter (TREE_VEC_ELT (p, i), TFF_PLAIN_IDENTIFIER);
 	  pp_cxx_whitespace (cxx_pp);
 	  pp_equal (cxx_pp);
@@ -301,7 +302,7 @@  dump_template_bindings (tree parms, tree args, VEC
 	    pp_string (cxx_pp, M_("<missing>"));
 
 	  ++arg_idx;
-	  need_comma = 1;
+	  need_semicolon = true;
 	}
 
       parms = TREE_CHAIN (parms);
@@ -313,8 +314,8 @@  dump_template_bindings (tree parms, tree args, VEC
 
   FOR_EACH_VEC_ELT (tree, typenames, i, t)
     {
-      if (need_comma)
-	pp_separate_with_comma (cxx_pp);
+      if (need_semicolon)
+	pp_separate_with_semicolon (cxx_pp);
       dump_type (t, TFF_PLAIN_IDENTIFIER);
       pp_cxx_whitespace (cxx_pp);
       pp_equal (cxx_pp);