aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mmitchell@usa.net>1998-01-29 11:06:22 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-01-29 06:06:22 -0500
commit7bf2682f3ff7a8a67eb33a022b435f90f547af25 (patch)
treebe8e6b3632153ed218587e2bd2c340b15ecaf8d3
parentc25520e8b93f2c1e367dfb29c01dbffabf7b7762 (diff)
downloadgcc-7bf2682f3ff7a8a67eb33a022b435f90f547af25.zip
gcc-7bf2682f3ff7a8a67eb33a022b435f90f547af25.tar.gz
gcc-7bf2682f3ff7a8a67eb33a022b435f90f547af25.tar.bz2
pt.c (convert_nontype_argument): Move check for is_overloaded_fn early to avoid bogus error.
* pt.c (convert_nontype_argument): Move check for is_overloaded_fn early to avoid bogus error. Handle overloaded function names provided as template arguments correctly. (coerce_template_parms): Don't mishandle overloaded functions when dealing with template template parameters. (lookup_template_class): Issue an error message, rather than crashing, when the TYPE_DECL provided is not a template type. From-SVN: r17552
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/pt.c24
2 files changed, 25 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6d033b7..67391f8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,13 @@
+Thu Jan 29 10:39:30 1998 Mark Mitchell <mmitchell@usa.net>
+
+ * pt.c (convert_nontype_argument): Move check for is_overloaded_fn
+ early to avoid bogus error. Handle overloaded function
+ names provided as template arguments correctly.
+ (coerce_template_parms): Don't mishandle overloaded functions when
+ dealing with template template parameters.
+ (lookup_template_class): Issue an error message, rather than
+ crashing, when the TYPE_DECL provided is not a template type.
+
Wed Jan 28 23:14:44 1998 Jason Merrill <jason@yorick.cygnus.com>
* class.c (instantiate_type): Don't just return a known type if
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 8a16203..77672b1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -1417,9 +1417,17 @@ convert_nontype_argument (type, expr)
if (INTEGRAL_TYPE_P (expr_type) && TREE_READONLY_DECL_P (expr))
expr = decl_constant_value (expr);
- if (INTEGRAL_TYPE_P (expr_type)
- || TYPE_PTRMEM_P (expr_type)
- || TYPE_PTRMEMFUNC_P (expr_type))
+ if (is_overloaded_fn (expr))
+ /* OK for now. We'll check that it has external linkage later.
+ Check this first since if expr_type is the unknown_type_node
+ we would otherwise complain below. */
+ ;
+ else if (INTEGRAL_TYPE_P (expr_type)
+ || TYPE_PTRMEM_P (expr_type)
+ || TYPE_PTRMEMFUNC_P (expr_type)
+ /* The next two are g++ extensions. */
+ || TREE_CODE (expr_type) == REAL_TYPE
+ || TREE_CODE (expr_type) == COMPLEX_TYPE)
{
if (! TREE_CONSTANT (expr))
{
@@ -1474,9 +1482,6 @@ convert_nontype_argument (type, expr)
if (!TREE_PUBLIC (expr))
goto bad_argument;
}
- else if (is_overloaded_fn (expr))
- /* OK for now. We'll check that it has external linkage later. */
- ;
else
{
cp_error ("object `%E' cannot be used as template argument", expr);
@@ -1526,8 +1531,7 @@ convert_nontype_argument (type, expr)
tree fns;
tree fn;
- if (TYPE_PTRFN_P (expr_type) ||
- expr_type == unknown_type_node)
+ if (TREE_CODE (expr) == ADDR_EXPR)
fns = TREE_OPERAND (expr, 0);
else
fns = expr;
@@ -1819,7 +1823,7 @@ coerce_template_parms (parms, arglist, in_decl,
/* In case we are checking arguments inside a template template
parameter, ARG that does not come from default argument is
also a TREE_LIST node */
- if (TREE_CODE (arg) == TREE_LIST)
+ if (TREE_CODE (arg) == TREE_LIST && ! is_overloaded_fn (arg))
{
is_tmpl_parm = 1;
arg = TREE_VALUE (arg);
@@ -2227,6 +2231,8 @@ lookup_template_class (d1, arglist, in_decl, context)
}
else if (TREE_CODE (d1) == TYPE_DECL && IS_AGGR_TYPE (TREE_TYPE (d1)))
{
+ if (CLASSTYPE_TEMPLATE_INFO (TREE_TYPE (d1)) == NULL_TREE)
+ return error_mark_node;
template = CLASSTYPE_TI_TEMPLATE (TREE_TYPE (d1));
d1 = DECL_NAME (template);
}