re PR c++/45487 (Request to change comma to semicolon in error message)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 27 Sep 2011 01:56:17 +0000 (01:56 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 27 Sep 2011 01:56:17 +0000 (01:56 +0000)
/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.

From-SVN: r179226

gcc/cp/ChangeLog
gcc/cp/error.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/diagnostic/bindings1.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.pt/memtemp77.C

index d1c79469a39d868195753ad0a3af29fe6ee296fd..9de69c864720a3480c6344d8a47264d1e6fe4194 100644 (file)
@@ -1,3 +1,9 @@
+2011-09-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/45487
+       * error.c (dump_template_bindings): Separate bindings with semicolons
+       instead of commas.
+
 2011-09-26  Jason Merrill  <jason@redhat.com>
 
        PR c++/50512
index 392f304ef92ca1eb5090c6b51f7c5d7e28c4d392..4d12a0dd43d36950a661c2ab3a64f1233e604295 100644 (file)
@@ -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(tree,gc)* typenames)
          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(tree,gc)* typenames)
            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(tree,gc)* typenames)
 
   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);
index 14476085743696516cc5f078bba4d03819e27235..7832453f47d527819617171a1a9c88724e9ac2c9 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2011-09-26  David S. Miller  <davem@davemloft.net>
 
        * gcc.target/sparc/wrgsr.c: New test.
diff --git a/gcc/testsuite/g++.dg/diagnostic/bindings1.C b/gcc/testsuite/g++.dg/diagnostic/bindings1.C
new file mode 100644 (file)
index 0000000..4972377
--- /dev/null
@@ -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 e3ca5298d4f6b5a30bcc9341d6672b3ebabfab45..6dd4b546c0c6fda6bb7c85d8948a259d3d51aff1 100644 (file)
@@ -19,7 +19,7 @@ const char* S3<char>::h(int) { return __PRETTY_FUNCTION__; }
 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;