diff options
author | Nathan Sidwell <nathan@codesourcery.com> | 2002-01-02 12:50:11 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2002-01-02 12:50:11 +0000 |
commit | 833aa4c4149ce0fa84968a03fe51a13575381d79 (patch) | |
tree | 9eda4828ff2460753b02042e25caf1b141568068 | |
parent | 18976b21446cfafe728b739b7220fd02f4ea5328 (diff) | |
download | gcc-833aa4c4149ce0fa84968a03fe51a13575381d79.zip gcc-833aa4c4149ce0fa84968a03fe51a13575381d79.tar.gz gcc-833aa4c4149ce0fa84968a03fe51a13575381d79.tar.bz2 |
re PR c++/35 (template operator () lookup fails)
cp:
PR c++/35
* cp-tree.h (DECL_LANG_FLAG_0): Used for PARM_DECL too.
(DECL_TEMPLATE_PARM_P): A PARM_DECL might be one too.
* pt.c (process_template_parm): SET_DECL_TEMPLATE_PARM_P on the
PARM_DECL.
(tsubst_template_parms): Break up loop statements.
(tsubst_decl, case PARM_DECL): Copy DECL_TEMPLATE_PARM_P. Template
parm PARM_DECLs don't get promoted.
testsuite:
* g++.dg/template/ntp.C: New test.
From-SVN: r48470
-rw-r--r-- | gcc/cp/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 3 | ||||
-rw-r--r-- | gcc/cp/pt.c | 27 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 2 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/template/ntp1.C | 24 |
5 files changed, 54 insertions, 13 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index ef4c0dd..4751ae9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,16 @@ 2002-01-02 Nathan Sidwell <nathan@codesourcery.com> + PR c++/35 + * cp-tree.h (DECL_LANG_FLAG_0): Used for PARM_DECL too. + (DECL_TEMPLATE_PARM_P): A PARM_DECL might be one too. + * pt.c (process_template_parm): SET_DECL_TEMPLATE_PARM_P on the + PARM_DECL. + (tsubst_template_parms): Break up loop statements. + (tsubst_decl, case PARM_DECL): Copy DECL_TEMPLATE_PARM_P. Template + parm PARM_DECLs don't get promoted. + +2002-01-02 Nathan Sidwell <nathan@codesourcery.com> + PR c++/5123 * typeck.c (build_component_ref): Cope with a TEMPLATE_ID_EXPR. (build_x_function_call): Cope with a COMPONENT_REF containing a diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 45b8fbf..f08f0ac 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -87,7 +87,7 @@ Boston, MA 02111-1307, USA. */ Usage of DECL_LANG_FLAG_?: 0: DECL_ERROR_REPORTED (in VAR_DECL). - DECL_TEMPLATE_PARM_P (in CONST_DECL, TYPE_DECL, or TEMPLATE_DECL) + DECL_TEMPLATE_PARM_P (in PARM_DECL, CONST_DECL, TYPE_DECL, or TEMPLATE_DECL) DECL_LOCAL_FUNCTION_P (in FUNCTION_DECL) DECL_MUTABLE_P (in FIELD_DECL) 1: C_TYPEDEF_EXPLICITLY_SIGNED (in TYPE_DECL). @@ -2719,6 +2719,7 @@ enum ptrmemfunc_vbit_where_t #define DECL_TEMPLATE_PARM_P(NODE) \ (DECL_LANG_FLAG_0 (NODE) \ && (TREE_CODE (NODE) == CONST_DECL \ + || TREE_CODE (NODE) == PARM_DECL \ || TREE_CODE (NODE) == TYPE_DECL \ || TREE_CODE (NODE) == TEMPLATE_DECL)) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 3a0921f..4f20635 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -1935,6 +1935,7 @@ process_template_parm (list, next) /* is a const-param */ parm = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm), PARM, 0, NULL); + SET_DECL_TEMPLATE_PARM_P (parm); /* [temp.param] @@ -5409,17 +5410,16 @@ tsubst_template_parms (parms, args, complain) for (i = 0; i < TREE_VEC_LENGTH (new_vec); ++i) { - tree default_value = - TREE_PURPOSE (TREE_VEC_ELT (TREE_VALUE (parms), i)); - tree parm_decl = - TREE_VALUE (TREE_VEC_ELT (TREE_VALUE (parms), i)); - - TREE_VEC_ELT (new_vec, i) - = build_tree_list (maybe_fold_nontype_arg ( - tsubst_expr (default_value, args, complain, - NULL_TREE)), - tsubst (parm_decl, args, complain, - NULL_TREE)); + tree tuple = TREE_VEC_ELT (TREE_VALUE (parms), i); + tree default_value = TREE_PURPOSE (tuple); + tree parm_decl = TREE_VALUE (tuple); + + parm_decl = tsubst (parm_decl, args, complain, NULL_TREE); + default_value = tsubst_expr (default_value, args, + complain, NULL_TREE); + tuple = build_tree_list (maybe_fold_nontype_arg (default_value), + parm_decl); + TREE_VEC_ELT (new_vec, i) = tuple; } *new_parms = @@ -5909,6 +5909,9 @@ tsubst_decl (t, args, type) case PARM_DECL: { r = copy_node (t); + if (DECL_TEMPLATE_PARM_P (t)) + SET_DECL_TEMPLATE_PARM_P (r); + TREE_TYPE (r) = type; c_apply_type_quals_to_decl (cp_type_quals (type), r); @@ -5919,7 +5922,7 @@ tsubst_decl (t, args, type) /*complain=*/1, in_decl); DECL_CONTEXT (r) = NULL_TREE; - if (PROMOTE_PROTOTYPES + if (!DECL_TEMPLATE_PARM_P (r) && PROMOTE_PROTOTYPES && INTEGRAL_TYPE_P (type) && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) DECL_ARG_TYPE (r) = integer_type_node; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dac37bd..d08a707 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,7 @@ 2002-01-02 Nathan Sidwell <nathan@codesourcery.com> + * g++.dg/template/ntp.C: New test. + * g++.dg/other/component1.C: New test. * g++.dg/template/ttp3.C: New test. diff --git a/gcc/testsuite/g++.dg/template/ntp1.C b/gcc/testsuite/g++.dg/template/ntp1.C new file mode 100644 index 0000000..98698e9 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/ntp1.C @@ -0,0 +1,24 @@ +// { dg-do compile } + +// Copyright (C) 2001 Free Software Foundation, Inc. +// Contributed by Nathan Sidwell 26 Dec 2001 <nathan@codesourcery.com> + +// PR 35. We were default promoting template PARM_DECLs + +template <short B> class R {}; + +template <class T> class A +{ + public: + template <short B> + void operator() (R<B> const &); +}; + +int main() { + A<int> a; + R<1> r; + + a (r); + + return 0; +} |