diff options
author | Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net> | 2001-08-11 12:21:17 +0000 |
---|---|---|
committer | Kriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org> | 2001-08-11 12:21:17 +0000 |
commit | 4d5f3fbd61ad7e6a13424fa720bda3888d6ef429 (patch) | |
tree | 257e9e80272c3ee42c1a95508d54acfe64463c0e /gcc/cp/pt.c | |
parent | 91b54f7f3fcabd08aaa16079441956e7d3d8bebf (diff) | |
download | gcc-4d5f3fbd61ad7e6a13424fa720bda3888d6ef429.zip gcc-4d5f3fbd61ad7e6a13424fa720bda3888d6ef429.tar.gz gcc-4d5f3fbd61ad7e6a13424fa720bda3888d6ef429.tar.bz2 |
pt.c (maybe_fold_nontype_arg): Use TREE_TYPE of ARG as the criterion to avoid rebuilding expression tree...
* pt.c (maybe_fold_nontype_arg): Use TREE_TYPE of ARG as the
criterion to avoid rebuilding expression tree instead of
processing_template_decl.
* g++.dg/template/unify1.C: New test.
From-SVN: r44793
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r-- | gcc/cp/pt.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1f40089..853fd81 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -5280,12 +5280,7 @@ static tree maybe_fold_nontype_arg (arg) tree arg; { - /* If we're not in a template, ARG is already as simple as it's going to - get, and trying to reprocess the trees will break. */ - if (! processing_template_decl) - return arg; - - if (!TYPE_P (arg) && !uses_template_parms (arg)) + if (arg && !TYPE_P (arg) && !uses_template_parms (arg)) { /* Sometimes, one of the args was an expression involving a template constant parameter, like N - 1. Now that we've @@ -5295,10 +5290,18 @@ maybe_fold_nontype_arg (arg) fool build_expr_from_tree() into building an actual tree. */ - int saved_processing_template_decl = processing_template_decl; - processing_template_decl = 0; - arg = fold (build_expr_from_tree (arg)); - processing_template_decl = saved_processing_template_decl; + /* If the TREE_TYPE of ARG is not NULL_TREE, ARG is already + as simple as it's going to get, and trying to reprocess + the trees will break. */ + if (!TREE_TYPE (arg)) + { + int saved_processing_template_decl = processing_template_decl; + processing_template_decl = 0; + arg = build_expr_from_tree (arg); + processing_template_decl = saved_processing_template_decl; + } + + arg = fold (arg); } return arg; } |