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
This commit is contained in:
Nathan Sidwell 2002-01-02 12:50:11 +00:00 committed by Nathan Sidwell
parent 18976b2144
commit 833aa4c414
5 changed files with 54 additions and 13 deletions

View file

@ -1,3 +1,14 @@
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

View file

@ -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))

View file

@ -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;

View file

@ -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.

View file

@ -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;
}