diff mbox

C++ PATCH for c++/47125 (ICE with template elaborated-type-specifier)

Message ID 4D7B179D.6090309@redhat.com
State New
Headers show

Commit Message

Jason Merrill March 12, 2011, 6:50 a.m. UTC
A straightforward case of some errors that were not properly protected 
by checking complain.

Tested x86_64-pc-linux-gnu, applied to trunk.
commit 49d36af37792ed3f1359f80443bc2ef9a25270c1
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 11 21:32:40 2011 -0500

    	PR c++/47125
    	* pt.c (tsubst) [TYPENAME_TYPE]: Only give errors if tf_error.
diff mbox

Patch

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ab2aea3..95b82ee 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -10948,11 +10948,21 @@  tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	if (TREE_CODE (f) != TYPENAME_TYPE)
 	  {
 	    if (TYPENAME_IS_ENUM_P (t) && TREE_CODE (f) != ENUMERAL_TYPE)
-	      error ("%qT resolves to %qT, which is not an enumeration type",
-		     t, f);
+	      {
+		if (complain & tf_error)
+		  error ("%qT resolves to %qT, which is not an enumeration type",
+			 t, f);
+		else
+		  return error_mark_node;
+	      }
 	    else if (TYPENAME_IS_CLASS_P (t) && !CLASS_TYPE_P (f))
-	      error ("%qT resolves to %qT, which is is not a class type",
-		     t, f);
+	      {
+		if (complain & tf_error)
+		  error ("%qT resolves to %qT, which is is not a class type",
+			 t, f);
+		else
+		  return error_mark_node;
+	      }
 	  }
 
 	return cp_build_qualified_type_real
diff --git a/gcc/testsuite/g++.dg/template/error45.C b/gcc/testsuite/g++.dg/template/error45.C
new file mode 100644
index 0000000..454acc6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/error45.C
@@ -0,0 +1,22 @@ 
+// PR c++/47125
+
+template < bool, typename >
+struct enable_if {};
+
+template < typename T >
+struct enable_if< true, T >
+{
+    typedef T type;
+};
+
+template < typename T >
+struct enable_if< true, T >::type
+f( T x );
+
+void
+g( void )
+{
+  f< int >( 0 );		// { dg-error "no match" }
+}
+
+// { dg-prune-output "note" }