OSDN Git Service

* pt.c (tsubst_function_type): Do not permit function types which
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Nov 2004 18:45:33 +0000 (18:45 +0000)
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Nov 2004 18:45:33 +0000 (18:45 +0000)
return arrays or functions.

* g++.dg/template/deduce3.C: New test.

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

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

index abfc86a..94f0d02 100644 (file)
@@ -1,5 +1,8 @@
 2004-11-24  Mark Mitchell  <mark@codesourcery.com>
 
+       * pt.c (tsubst_function_type): Do not permit function types which
+       return arrays or functions.
+
        PR c++/18586
        * parser.c (cp_parser_init_declarator): Do not pop scope twice.
 
index 34fd27b..c171f31 100644 (file)
@@ -6732,6 +6732,22 @@ tsubst_function_type (tree t,
   return_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
   if (return_type == error_mark_node)
     return error_mark_node;
+  /* The standard does not presently indicate that creation of a
+     function type with an invalid return type is a deduction failure.
+     However, that is clearly analagous to creating an array of "void"
+     or a reference to a reference.  This is core issue #486.  */ 
+  if (TREE_CODE (return_type) == ARRAY_TYPE
+      || TREE_CODE (return_type) == FUNCTION_TYPE)
+    {
+      if (complain & tf_error)
+       {
+         if (TREE_CODE (return_type) == ARRAY_TYPE)
+           error ("function returning an array");
+         else
+           error ("function returning a function");
+       }
+      return error_mark_node;
+    }
 
   /* Substitute the argument types.  */
   arg_types = tsubst_arg_types (TYPE_ARG_TYPES (t), args,
index d569fb7..f647b33 100644 (file)
@@ -1,5 +1,7 @@
 2004-11-24  Mark Mitchell  <mark@codesourcery.com>
 
+       * g++.dg/template/deduce3.C: New test. 
+
        PR c++/18586
        * g++.dg/template/crash27.C: New test.