This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: PR 10468
- From: Mark Mitchell <mark at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 27 Jun 2003 15:47:45 -0700
- Subject: C++ PATCH: PR 10468
- Reply-to: mark at codesourcery dot com
This patch fixes a problem with cv-qualified "typeof" types.
The problem is latent on the mainline (because the parser reduces
typeof when applied to a non-dependent type), but it could occur there
as well, so I've applied the patch to both the branch and the
mainline.
Tested on i686-pc-linux-gnu, applied on the mainline and on the
branch.
--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
2003-06-27 Mark Mitchell <mark@codesourcery.com>
PR c++/10468
* pt.c (tsubst): Handle qualified TYPEOF_TYPEs correctly.
2003-06-27 Mark Mitchell <mark@codesourcery.com>
PR c++/10468
* g++.dg/ext/typeof5.C: New test.
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.635.2.30
diff -c -5 -p -r1.635.2.30 pt.c
*** cp/pt.c 20 Jun 2003 15:46:39 -0000 1.635.2.30
--- cp/pt.c 27 Jun 2003 22:19:52 -0000
*************** tsubst (t, args, complain, in_decl)
*** 7186,7196 ****
{
tree e1 = tsubst_expr (TYPE_FIELDS (t), args, complain, in_decl);
if (e1 == error_mark_node)
return error_mark_node;
! return TREE_TYPE (e1);
}
default:
sorry ("use of `%s' in template",
tree_code_name [(int) TREE_CODE (t)]);
--- 7186,7199 ----
{
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",
tree_code_name [(int) TREE_CODE (t)]);
Index: testsuite/g++.dg/ext/typeof5.C
===================================================================
RCS file: testsuite/g++.dg/ext/typeof5.C
diff -N testsuite/g++.dg/ext/typeof5.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/ext/typeof5.C 27 Jun 2003 22:19:52 -0000
***************
*** 0 ****
--- 1,17 ----
+ // { dg-options "" }
+
+ template <class T>
+ void test1() {
+ int x = 0;
+ const typeof(x) & t1 = x+0;
+ }
+
+ void test2() {
+ int x = 0;
+ const typeof(x) & t1 = x+0;
+ }
+
+ int main() {
+ test1<int>();
+ test2 ();
+ }