aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/pt.c
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2004-11-24 18:45:33 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2004-11-24 18:45:33 +0000
commit6e2993bf5b71c17c2b60e0dec787750f44925e66 (patch)
tree305ee90bc38b92a36da848565cf8b0e4401db6bb /gcc/cp/pt.c
parentf5523e6dedd24c21d7127775a6322399eccefcc9 (diff)
downloadgcc-6e2993bf5b71c17c2b60e0dec787750f44925e66.zip
gcc-6e2993bf5b71c17c2b60e0dec787750f44925e66.tar.gz
gcc-6e2993bf5b71c17c2b60e0dec787750f44925e66.tar.bz2
pt.c (tsubst_function_type): Do not permit function types which return arrays or functions.
* pt.c (tsubst_function_type): Do not permit function types which return arrays or functions. * g++.dg/template/deduce3.C: New test. From-SVN: r91186
Diffstat (limited to 'gcc/cp/pt.c')
-rw-r--r--gcc/cp/pt.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 34fd27b..c171f31 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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,