]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/34272 (ICE with invalid template specialization)
authorPaolo Carlini <paolo.carlini@oracle.com>
Tue, 11 May 2010 20:53:36 +0000 (20:53 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 11 May 2010 20:53:36 +0000 (20:53 +0000)
/cp
2010-05-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/34272
PR c++/43630
PR c++/34491
* pt.c (process_partial_specialization): Return error_mark_node
in case of unused template parameters in partial specialization.

/testsuite
2010-05-11  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/34272
PR c++/43630
PR c++/34491
* g++.dg/template/crash97.C: New.
* g++.dg/template/crash98.C: Likewise.
* g++.dg/template/crash99.C: Likewise.
* g++.dg/cpp0x/pr31439.C: Adjust.
* g++.dg/template/crash95.C: Likewise.

From-SVN: r159295

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/pr31439.C
gcc/testsuite/g++.dg/template/crash95.C
gcc/testsuite/g++.dg/template/crash97.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/crash98.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/crash99.C [new file with mode: 0644]

index 597f8f1bcf985e3dc53770c956a6aa1bdea7c561..58a57e05e5144d4223090b65655cf17b6c1e4f66 100644 (file)
@@ -1,3 +1,11 @@
+2010-05-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/34272
+       PR c++/43630
+       PR c++/34491
+       * pt.c (process_partial_specialization): Return error_mark_node
+       in case of unused template parameters in partial specialization.
+
 2010-05-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/44062
index 06f5d9f2313dd06f112c38e8b0e6ee462811554f..1ff1fe2b5770030c771775e85f94c7393f07bf07 100644 (file)
@@ -1,6 +1,6 @@
 /* Handle parameterized types (templates) for GNU C++.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-   2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
    Rewritten by Jason Merrill (jason@cygnus.com).
@@ -3837,7 +3837,7 @@ process_partial_specialization (tree decl)
   int nargs = TREE_VEC_LENGTH (inner_args);
   int ntparms;
   int  i;
-  int did_error_intro = 0;
+  bool did_error_intro = false;
   struct template_parm_data tpd;
   struct template_parm_data tpd2;
 
@@ -3899,12 +3899,15 @@ process_partial_specialization (tree decl)
        if (!did_error_intro)
          {
            error ("template parameters not used in partial specialization:");
-           did_error_intro = 1;
+           did_error_intro = true;
          }
 
        error ("        %qD", TREE_VALUE (TREE_VEC_ELT (inner_parms, i)));
       }
 
+  if (did_error_intro)
+    return error_mark_node;
+
   /* [temp.class.spec]
 
      The argument list of the specialization shall not be identical to
index ee0fab84ca2518698ff436f1e7b78157379f822d..11d07465150fa4efe2896f544aa50d746c7385af 100644 (file)
@@ -1,3 +1,14 @@
+2010-05-11  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/34272
+       PR c++/43630
+       PR c++/34491
+       * g++.dg/template/crash97.C: New.
+       * g++.dg/template/crash98.C: Likewise.
+       * g++.dg/template/crash99.C: Likewise.
+       * g++.dg/cpp0x/pr31439.C: Adjust.
+       * g++.dg/template/crash95.C: Likewise.
+
 2010-05-11  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/44071
index 420dc082f086073552bbc459d04e8310407d933d..9d22b56c2f8bc95b8bfc038d09dbf5dcd635efaa 100644 (file)
@@ -1,8 +1,8 @@
 // { dg-options "-std=c++0x" }
-template<typename...> struct A;
+template<typename...> struct A; // { dg-error "declaration" }
 
 template<char> struct A<> {}; // { dg-error "not used in partial specialization|anonymous" }
 
-template<typename T, typename... U> struct A<T, U...> : A<U...> {};
+template<typename T, typename... U> struct A<T, U...> : A<U...> {}; // { dg-error "incomplete type" }
 
 A<int> a;
index 959a9d066ac69c20b2f08e3d36486d7ef30ec4cc..2ad9e9816666fd5fc98d8fda3ca00ab48e4a5bb8 100644 (file)
@@ -8,4 +8,4 @@ template < typename > struct S
   };
 };
 
-S < int > s(0);
+S < int > s(0); // { dg-error "incomplete type" }
diff --git a/gcc/testsuite/g++.dg/template/crash97.C b/gcc/testsuite/g++.dg/template/crash97.C
new file mode 100644 (file)
index 0000000..3d177f4
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/34272
+
+template<typename> struct A {};
+
+template<typename> struct A<int> // { dg-error "not used|template\\-parameter" }
+{
+  template<int> void foo();
+};
+
+void bar()
+{
+  A<int> a; // { dg-error "incomplete type" }
+  a.foo<0>(); // { dg-error "expected" }
+}
diff --git a/gcc/testsuite/g++.dg/template/crash98.C b/gcc/testsuite/g++.dg/template/crash98.C
new file mode 100644 (file)
index 0000000..e3c224d
--- /dev/null
@@ -0,0 +1,14 @@
+// PR c++/43630
+
+template < typename > struct A; // { dg-error "declaration" }
+
+template < typename > struct A < int > // { dg-error "not used|template\\-parameter" }
+{
+  int i;
+  int f ();
+};
+
+int A < int >::f () // { dg-error "incomplete type" }
+{
+  return i;
+}
diff --git a/gcc/testsuite/g++.dg/template/crash99.C b/gcc/testsuite/g++.dg/template/crash99.C
new file mode 100644 (file)
index 0000000..606d3e3
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/34491
+
+template<typename> struct A;
+
+template<0> struct A<int> // { dg-error "expected|template|anonymous" }
+{
+  static const int i = 0;
+};
+
+int n = A<int>::i; // { dg-error "incomplete type" }
This page took 0.12001 seconds and 5 git commands to generate.