From 5c62640040b6ce4932fa2e4574afa5bafa73fce7 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Fri, 16 Sep 2005 01:50:26 +0000 Subject: [PATCH] PR c++/23896 * pt.c (tsubst_aggr_type): Make sure skip_evaluation is false when processing template arguments. PR c++/23896 * g++.dg/template/static17.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104336 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 20 +++++++++++++++----- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/static17.C | 13 +++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/template/static17.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 868ef3a..188189f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2005-09-15 Mark Mitchell + PR c++/23896 + * pt.c (tsubst_aggr_type): Make sure skip_evaluation is false when + processing template arguments. + * pt.c (check_explicit_instantiation_namespace): Fix typo. PR c++/13140 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8840d27..ece9614 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -6069,6 +6069,11 @@ tsubst_aggr_type (tree t, tree argvec; tree context; tree r; + bool saved_skip_evaluation; + + /* In "sizeof(X)" we need to evaluate "I". */ + saved_skip_evaluation = skip_evaluation; + skip_evaluation = false; /* First, determine the context for the type we are looking up. */ @@ -6089,12 +6094,17 @@ tsubst_aggr_type (tree t, argvec = tsubst_template_args (TYPE_TI_ARGS (t), args, complain, in_decl); if (argvec == error_mark_node) - return error_mark_node; - - r = lookup_template_class (t, argvec, in_decl, context, - entering_scope, complain); + r = error_mark_node; + else + { + r = lookup_template_class (t, argvec, in_decl, context, + entering_scope, complain); + r = cp_build_qualified_type_real (r, TYPE_QUALS (t), complain); + } + + skip_evaluation = saved_skip_evaluation; - return cp_build_qualified_type_real (r, TYPE_QUALS (t), complain); + return r; } else /* This is not a template type, so there's nothing to do. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 39fc06a..e9b96a9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-09-15 Mark Mitchell + + PR c++/23896 + * g++.dg/template/static17.C: New test. + 2005-09-15 Joseph S. Myers PR c++/23139 diff --git a/gcc/testsuite/g++.dg/template/static17.C b/gcc/testsuite/g++.dg/template/static17.C new file mode 100644 index 0000000..bf79bcc --- /dev/null +++ b/gcc/testsuite/g++.dg/template/static17.C @@ -0,0 +1,13 @@ +// PR c++/23896 + +template struct X {}; + +template struct length { + static const int value = 2; +}; + +template void foo () { + sizeof(X::value>); +} + +template void foo(); -- 2.7.4