This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 13635
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 18 Jan 2004 16:49:47 -0800
- Subject: C++ PATCH: PR 13635
- Reply-to: mark at codesourcery dot com
This patch fixes a crash when using the "typeof" extension in a
template.
Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2004-01-18 Mark Mitchell <mark@codesourcery.com>
PR c++/13635
* pt.c (tsubst): Use finish_typeof.
2004-01-18 Mark Mitchell <mark@codesourcery.com>
PR c++/13635
* g++.dg/ext/typeof7.C: New test.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.816
diff -c -5 -p -r1.816 pt.c
*** cp/pt.c 15 Jan 2004 15:00:34 -0000 1.816
--- cp/pt.c 19 Jan 2004 00:46:06 -0000
*************** tsubst (tree t, tree args, tsubst_flags_
*** 7104,7120 ****
return build_nt (TREE_CODE (t), e1, e2);
}
case TYPEOF_TYPE:
{
! tree e1 = tsubst_expr (TYPE_FIELDS (t), args, complain, in_decl);
! if (e1 == error_mark_node)
! return error_mark_node;
! return cp_build_qualified_type_real (TREE_TYPE (e1),
cp_type_quals (t)
! | cp_type_quals (TREE_TYPE (e1)),
complain);
}
default:
sorry ("use of `%s' in template",
--- 7104,7120 ----
return build_nt (TREE_CODE (t), e1, e2);
}
case TYPEOF_TYPE:
{
! tree type;
! type = finish_typeof (tsubst_expr (TYPE_FIELDS (t), args, complain,
! in_decl));
! return cp_build_qualified_type_real (type,
cp_type_quals (t)
! | cp_type_quals (type),
complain);
}
default:
sorry ("use of `%s' in template",
Index: testsuite/g++.dg/ext/typeof7.C
===================================================================
RCS file: testsuite/g++.dg/ext/typeof7.C
diff -N testsuite/g++.dg/ext/typeof7.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/ext/typeof7.C 19 Jan 2004 00:46:06 -0000
***************
*** 0 ****
--- 1,6 ----
+ // PR c++/13635
+ // { dg-options "" }
+
+ template<int n> class X {template<class Y> typeof(Y::y) foo();};
+ X<0> x;
+