OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Jan 2012 00:12:41 +0000 (00:12 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 27 Jan 2012 00:12:41 +0000 (00:12 +0000)
2012-01-26  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51370
* error.c (dump_decl, [TEMPLATE_ID_EXPR]): Handle error_mark_node
as TREE_OPERAND (t, 1).

/testsuite
2012-01-26  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51370
* g++.dg/template/crash112.C: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183593 138bc75d-0d04-0410-961f-82ee72b054a4

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

index e4a3d6f..3df6d11 100644 (file)
@@ -1,3 +1,9 @@
+2012-01-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51370
+       * error.c (dump_decl, [TEMPLATE_ID_EXPR]): Handle error_mark_node
+       as TREE_OPERAND (t, 1).
+
 2012-01-24  Jason Merrill  <jason@redhat.com>
 
        PR c++/51917
index 62b47ca..09c6cae 100644 (file)
@@ -1,7 +1,7 @@
 /* Call-backs for C++ error reporting.
    This code is non-reentrant.
    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2003,
-   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
    Free Software Foundation, Inc.
    This file is part of GCC.
 
@@ -1118,14 +1118,17 @@ dump_decl (tree t, int flags)
     case TEMPLATE_ID_EXPR:
       {
        tree name = TREE_OPERAND (t, 0);
+       tree args = TREE_OPERAND (t, 1);
 
        if (is_overloaded_fn (name))
          name = DECL_NAME (get_first_fn (name));
        dump_decl (name, flags);
        pp_cxx_begin_template_argument_list (cxx_pp);
-       if (TREE_OPERAND (t, 1))
-         dump_template_argument_list (TREE_OPERAND (t, 1), flags);
-       pp_cxx_end_template_argument_list (cxx_pp);
+       if (args == error_mark_node)
+         pp_string (cxx_pp, M_("<template arguments error>"));
+       else if (args)
+         dump_template_argument_list (args, flags);
+       pp_cxx_end_template_argument_list (cxx_pp);
       }
       break;
 
index 21dfd91..f24d26f 100644 (file)
@@ -1,3 +1,8 @@
+2012-01-26  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51370
+       * g++.dg/template/crash112.C: New.
+
 2012-01-27  Richard Henderson  <rth@redhat.com>
 
        * gcc.dg/atomic-flag.c: Adjust for __GCC_ATOMIC_TEST_AND_SET_TRUEVAL.
diff --git a/gcc/testsuite/g++.dg/template/crash112.C b/gcc/testsuite/g++.dg/template/crash112.C
new file mode 100644 (file)
index 0000000..919c887
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/51370
+
+struct A
+{
+  template<typename> void foo() {}
+};
+
+template<void (A::*)()> struct B {}; // { dg-error "declaration" }
+
+template<int> struct C
+{
+  B<&A::foo<int int> > b; // { dg-error "declaration|type" }
+};
+
+C<0> c;