pt.c (determine_specialization): Tighten error-checking.
authorMark Mitchell <mark@codesourcery.com>
Sun, 18 Jul 1999 03:28:32 +0000 (03:28 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Sun, 18 Jul 1999 03:28:32 +0000 (03:28 +0000)
* pt.c (determine_specialization): Tighten error-checking.
(end_template_parm_list): Likewise.

From-SVN: r28147

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.oliva/template6.C

index fdc4b70c348ad1870cb0390e026893a47c8e8bab..090fc8620adc853086d7f802305878f1ae04c7a4 100644 (file)
@@ -1,3 +1,8 @@
+1999-07-17  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (determine_specialization): Tighten error-checking.
+       (end_template_parm_list): Likewise.
+
 1999-07-14  Mark Mitchell  <mark@codesourcery.com>
 
        * pt.c (check_default_tmpl_args): Handle friends defined in the
index 00e17be096b8894aa5d41d31ed35a0c5ba7296ca..6106852922ef155f5b46ff1512c0afa22a4e6aba 100644 (file)
@@ -974,9 +974,15 @@ determine_specialization (template_id, decl, targs_out,
     return error_mark_node;
 
   /* Check for baselinks. */
-  if (TREE_CODE (fns) == TREE_LIST)
+  if (BASELINK_P (fns))
     fns = TREE_VALUE (fns);
 
+  if (!is_overloaded_fn (fns))
+    {
+      cp_error ("`%D' is not a function template", fn);
+      return error_mark_node;
+    }
+
   for (; fns; fns = OVL_NEXT (fns))
     {
       tree tmpl;
@@ -1851,13 +1857,34 @@ end_template_parm_list (parms)
   int nparms;
   tree parm;
   tree saved_parmlist = make_tree_vec (list_length (parms));
+  int seen_def_arg_p = 0;
 
   current_template_parms
     = tree_cons (build_int_2 (0, processing_template_decl),
                 saved_parmlist, current_template_parms);
 
-  for (parm = parms, nparms = 0; parm; parm = TREE_CHAIN (parm), nparms++)
-    TREE_VEC_ELT (saved_parmlist, nparms) = parm;
+  for (parm = parms, nparms = 0; 
+       parm; 
+       parm = TREE_CHAIN (parm), nparms++)
+    {
+      /* [temp.param]
+        
+        If a template-parameter has a default template-argument, all
+        subsequent template-parameters shall have a default
+        template-argument supplied.  */
+      if (TREE_PURPOSE (parm))
+       seen_def_arg_p = 1;
+      else if (seen_def_arg_p)
+       {
+         /* Issue the error message.  */
+         cp_error ("no default argument for `%D'", TREE_VALUE (parm));
+         /* For better subsequent error-recovery, we indicate that
+            there should have been a default argument.  */
+         TREE_PURPOSE (parm) = error_mark_node;
+       }
+
+      TREE_VEC_ELT (saved_parmlist, nparms) = parm;
+    }
 
   --processing_template_parmlist;
 
index 3902d5d6b59d6648a4266a588298b9422afff2f6..159f190462dedf7e6a82e03f006ef06b73282e67 100644 (file)
@@ -5,7 +5,5 @@
 // by Alexandre Oliva <oliva@dcc.unicamp.br>
 // simplified from bug report by Meenaradchagan Vishnu <mvishnu@fore.com>
 
-// crash test - XFAIL *-*-*
-
 template <typename> struct foo {};
-template <> void foo();
+template <> void foo(); // ERROR - bad specialization