OSDN Git Service

/cp
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 19 Dec 2011 22:40:11 +0000 (22:40 +0000)
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 19 Dec 2011 22:40:11 +0000 (22:40 +0000)
2011-12-19  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51328
* pt.c (convert_template_argument): Early error out and return
error_mark_node for invalid uses of destructors as types.

/testsuite
2011-12-19  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/51328
* g++.dg/template/crash109.C: New.

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

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

index 3da96fe..8626e00 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-19  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51328
+       * pt.c (convert_template_argument): Early error out and return
+       error_mark_node for invalid uses of destructors as types.
+
 2011-12-19  Jason Merrill  <jason@redhat.com>
 
        PR c++/51530
 2011-12-19  Jason Merrill  <jason@redhat.com>
 
        PR c++/51530
index 769b610..820b1ff 100644 (file)
@@ -6445,8 +6445,16 @@ convert_template_argument (tree parm,
   if (requires_type && ! is_type && TREE_CODE (arg) == SCOPE_REF
       && TREE_CODE (TREE_OPERAND (arg, 0)) == TEMPLATE_TYPE_PARM)
     {
   if (requires_type && ! is_type && TREE_CODE (arg) == SCOPE_REF
       && TREE_CODE (TREE_OPERAND (arg, 0)) == TEMPLATE_TYPE_PARM)
     {
-      permerror (input_location, "to refer to a type member of a template parameter, "
-                "use %<typename %E%>", orig_arg);
+      if (TREE_CODE (TREE_OPERAND (arg, 1)) == BIT_NOT_EXPR)
+       {
+         if (complain & tf_error)
+           error ("invalid use of destructor %qE as a type", orig_arg);
+         return error_mark_node;
+       }
+
+      permerror (input_location,
+                "to refer to a type member of a template parameter, "
+                "use %<typename %E%>", orig_arg);
 
       orig_arg = make_typename_type (TREE_OPERAND (arg, 0),
                                     TREE_OPERAND (arg, 1),
 
       orig_arg = make_typename_type (TREE_OPERAND (arg, 0),
                                     TREE_OPERAND (arg, 1),
index 7b349c9..e520613 100644 (file)
@@ -1,3 +1,8 @@
+2011-12-19  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/51328
+       * g++.dg/template/crash109.C: New.
+
 2011-12-19  Jason Merrill  <jason@redhat.com>
 
        PR c++/51530
 2011-12-19  Jason Merrill  <jason@redhat.com>
 
        PR c++/51530
diff --git a/gcc/testsuite/g++.dg/template/crash109.C b/gcc/testsuite/g++.dg/template/crash109.C
new file mode 100644 (file)
index 0000000..28d9198
--- /dev/null
@@ -0,0 +1,6 @@
+// PR c++/51328
+
+template<typename T> struct A
+{
+  void foo(A<T::~T>);  // { dg-error "invalid use of destructor" }
+};