[patch] Fix PR c++/28051
Lee Millward
lee.millward@gmail.com
Sun Jun 18 21:38:00 GMT 2006
Hi,
The C++ front-end currently fails on the following invalid testcase
with a tree check failure in
mangle_conv_op_name_for_type:
template<int> struct A {};
template<int N> struct B : A<N>
{
using A<N>::operator typename A::X;
};
B<0> b;
This is because error_mark_node gets passed into
mangle_conv_op_name_for_type from tsubst_copy which can't handle it.
The proposed patch fixes this ICE by checking the return value from
tsubst in tsubst_copy before calling mangle_conv_op_name_for_type,
avoiding the ICE.
The second part of the patch addresses some follow up issues by making
push_class_level_binding and do_class_using_decl more robust in the
presence of error_mark_nodes.
Bootstrapped and regression tested on i686-pc-linux-gnu with no new
failures. Ok for mainline?
Cheers,
Lee.
:ADDPATCH c++:
cp/
2006-06-18 Lee Millward <lee.millward@gmail.com>
PR c++/28051
* pt.c (tsubst_copy): Check for tsubst
returning error_mark_node before calling
mangle_conv_op_name_for_type.
* name-lookup.c (push_class_level_binding): Robustify.
(do_class_using_decl): Likewise.
testsuite/
2006-06-18 Lee Millward <lee.millward@gmail.com>
PR c++/28051
* g++.dg/template/using13.C: New test.
-------------- next part --------------
Index: gcc/testsuite/g++.dg/template/using13.C
===================================================================
--- gcc/testsuite/g++.dg/template/using13.C (revision 0)
+++ gcc/testsuite/g++.dg/template/using13.C (revision 0)
@@ -0,0 +1,11 @@
+//PR c++/28051
+
+template<int> struct A {};
+
+template<int N> struct B : A<N>
+{
+ using A<N>::operator typename A<N>::X; // { dg-error "no type named" }
+};
+
+B<0> b;
+
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c (revision 114756)
+++ gcc/cp/pt.c (working copy)
@@ -8085,6 +8085,10 @@ tsubst_copy (tree t, tree args, tsubst_f
if (IDENTIFIER_TYPENAME_P (t))
{
tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
+
+ if(new_type == error_mark_node)
+ return error_mark_node;
+
return mangle_conv_op_name_for_type (new_type);
}
else
Index: gcc/cp/name-lookup.c
===================================================================
--- gcc/cp/name-lookup.c (revision 114756)
+++ gcc/cp/name-lookup.c (working copy)
@@ -2609,6 +2609,9 @@ push_class_level_binding (tree name, tre
if (!class_binding_level)
POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, true);
+ if(name == error_mark_node)
+ POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, false);
+
/* Check for invalid member names. */
gcc_assert (TYPE_BEING_DEFINED (current_class_type));
/* We could have been passed a tree list if this is an ambiguous
@@ -2826,7 +2829,7 @@ do_class_using_decl (tree scope, tree na
return NULL_TREE;
}
- if (!name_dependent_p)
+ if (!name_dependent_p && name != error_mark_node)
{
decl = lookup_member (binfo, name, 0, false);
if (!decl)
More information about the Gcc-patches
mailing list