diff mbox

[C++] PR 51328

Message ID 4EEF7F07.8070204@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Dec. 19, 2011, 6:14 p.m. UTC
Hi,

per the audit trail, treat BIT_NOT_EXPR specially, do not try to 
"adjust" it with make_typename_type. Tested x86_64-linux.

Thanks,
Paolo.

///////////////////////////
/cp
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.

Comments

Jason Merrill Dec. 19, 2011, 10:28 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: testsuite/g++.dg/template/crash109.C
===================================================================
--- testsuite/g++.dg/template/crash109.C	(revision 0)
+++ testsuite/g++.dg/template/crash109.C	(revision 0)
@@ -0,0 +1,6 @@ 
+// PR c++/51328
+
+template<typename T> struct A
+{
+  void foo(A<T::~T>);  // { dg-error "invalid use of destructor" }
+};
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 182488)
+++ cp/pt.c	(working copy)
@@ -6445,9 +6445,17 @@  convert_template_argument (tree 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),
 				     typename_type,