* pt.c (convert_nontype_argument): Move check for is_overloaded_fn
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Jan 1998 11:06:22 +0000 (11:06 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Jan 1998 11:06:22 +0000 (11:06 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@17552 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c

index 6d033b7..67391f8 100644 (file)
@@ -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
index 8a16203..77672b1 100644 (file)
@@ -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);
     }