From dce50630a39a2c30ea218efa600f2f8e28e069d6 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 27 Jun 2003 22:46:47 +0000 Subject: [PATCH] re PR c++/10468 (const typeof(x) is non-const, but only in templates) PR c++/10468 * pt.c (tsubst): Handle qualified TYPEOF_TYPEs correctly. PR c++/10468 * g++.dg/ext/typeof5.C: New test. From-SVN: r68615 --- gcc/cp/ChangeLog | 5 +++++ gcc/cp/pt.c | 5 ++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/ext/typeof6.C | 17 +++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/ext/typeof6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 3e1fa5d4ab09..69242ca97ee0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2003-06-27 Mark Mitchell + + PR c++/10468 + * pt.c (tsubst): Handle qualified TYPEOF_TYPEs correctly. + 2003-06-27 Mark Mitchell PR c++/10796 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 282c788180fb..75b3537e53a9 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7062,7 +7062,10 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) if (e1 == error_mark_node) return error_mark_node; - return TREE_TYPE (e1); + return cp_build_qualified_type_real (TREE_TYPE (e1), + cp_type_quals (t) + | cp_type_quals (TREE_TYPE (e1)), + complain); } default: diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b407402ed3f9..e551aae327aa 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-06-27 Mark Mitchell + + PR c++/10468 + * g++.dg/ext/typeof6.C: New test. + 2003-06-27 Mark Mitchell PR c++/10796 diff --git a/gcc/testsuite/g++.dg/ext/typeof6.C b/gcc/testsuite/g++.dg/ext/typeof6.C new file mode 100644 index 000000000000..ef75f255cb48 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/typeof6.C @@ -0,0 +1,17 @@ +// { dg-options "" } + +template +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(); + test2 (); +}