re PR c++/47125 (ICE occurs in combination with partial specialization and invalid...
authorJason Merrill <jason@redhat.com>
Sat, 12 Mar 2011 06:48:57 +0000 (01:48 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 12 Mar 2011 06:48:57 +0000 (01:48 -0500)
PR c++/47125
* pt.c (tsubst) [TYPENAME_TYPE]: Only give errors if tf_error.

From-SVN: r170896

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

index 64281fd684e80352c8c53ddb7d0d838b49ffd6c0..7c1e739ad70ce5a3bb844ec24025d9ac8ba646ae 100644 (file)
@@ -1,5 +1,8 @@
 2011-03-11  Jason Merrill  <jason@redhat.com>
 
+       PR c++/47125
+       * pt.c (tsubst) [TYPENAME_TYPE]: Only give errors if tf_error.
+
        PR c++/47144
        * parser.c (cp_parser_template_type_arg): Set
        type_definition_forbidden_message.
index ab2aea3b53679ccf89398f8492da8c6cd27a63d6..95b82ee579dd2916b59ee1eb4b3f03f3c8d6e8ee 100644 (file)
@@ -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
index 5ee1fcd933559242d7acc7a19810cb33b67a0609..9652b4aae30b78920f424bcd5cb4774ef5365133 100644 (file)
@@ -1,5 +1,7 @@
 2011-03-11  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/template/error45.C: New.
+
        * g++.dg/parse/no-type-defn1.C: New.
 
        * g++.dg/ext/attrib40.C: New.
diff --git a/gcc/testsuite/g++.dg/template/error45.C b/gcc/testsuite/g++.dg/template/error45.C
new file mode 100644 (file)
index 0000000..454acc6
--- /dev/null
@@ -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" }