From: Jason Merrill Date: Wed, 25 May 2011 19:51:54 +0000 (-0400) Subject: re PR c++/46245 ([C++0x] rejects function with late-specified return type as a non... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ce9b1898e5516ed5cdc444f1c0de82de34939181;p=gcc.git re PR c++/46245 ([C++0x] rejects function with late-specified return type as a non-type template parameter) PR c++/46245 * decl.c (grokdeclarator): Complain later for auto parameter. * pt.c (splice_late_return_type): Handle use in a template type-parameter. From-SVN: r174227 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 72e62d75f70..d78f18324ed 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2011-05-25 Jason Merrill + PR c++/46245 + * decl.c (grokdeclarator): Complain later for auto parameter. + * pt.c (splice_late_return_type): Handle use in a template + type-parameter. + PR c++/46696 * typeck.c (cp_build_modify_expr): Check DECL_DEFAULTED_FN. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d87a8372930..8000441d06f 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -8741,12 +8741,6 @@ grokdeclarator (const cp_declarator *declarator, || thread_p) error ("storage class specifiers invalid in parameter declarations"); - if (type_uses_auto (type)) - { - error ("parameter declared %"); - type = error_mark_node; - } - /* Function parameters cannot be constexpr. If we saw one, moan and pretend it wasn't there. */ if (constexpr_p) @@ -9727,6 +9721,12 @@ grokdeclarator (const cp_declarator *declarator, if (ctype || in_namespace) error ("cannot use %<::%> in parameter declaration"); + if (type_uses_auto (type)) + { + error ("parameter declared %"); + type = error_mark_node; + } + /* A parameter declared as an array of T is really a pointer to T. One declared as a function is really a pointer to a function. One declared as a member is really a pointer to member. */ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bb4515be6b7..c3c759e38aa 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -19315,7 +19315,12 @@ splice_late_return_type (tree type, tree late_return_type) return type; argvec = make_tree_vec (1); TREE_VEC_ELT (argvec, 0) = late_return_type; - if (processing_template_decl) + if (processing_template_parmlist) + /* For a late-specified return type in a template type-parameter, we + need to add a dummy argument level for its parmlist. */ + argvec = add_to_template_args + (make_tree_vec (processing_template_parmlist), argvec); + if (current_template_parms) argvec = add_to_template_args (current_template_args (), argvec); return tsubst (type, argvec, tf_warning_or_error, NULL_TREE); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 833d52eb635..3cc818adc80 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-05-25 Jason Merrill + * g++.dg/cpp0x/auto23.C: New. + * g++.dg/cpp0x/auto9.C: Adjust. + * g++.dg/cpp0x/defaulted29.C: New. * g++.dg/cpp0x/initlist51.C: New. diff --git a/gcc/testsuite/g++.dg/cpp0x/auto23.C b/gcc/testsuite/g++.dg/cpp0x/auto23.C new file mode 100644 index 00000000000..49b5a0eb9e8 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/auto23.C @@ -0,0 +1,4 @@ +// PR c++/46245 +// { dg-options -std=c++0x } + +templateint> struct A { }; diff --git a/gcc/testsuite/g++.dg/cpp0x/auto9.C b/gcc/testsuite/g++.dg/cpp0x/auto9.C index ab90be55844..142ef904f2d 100644 --- a/gcc/testsuite/g++.dg/cpp0x/auto9.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto9.C @@ -79,10 +79,10 @@ enum struct D : auto * { FF = 0 }; // { dg-error "must be an integral type|decl void bar () { - try { } catch (auto i) { } // { dg-error "invalid use of" } - try { } catch (auto) { } // { dg-error "invalid use of" } - try { } catch (auto *i) { } // { dg-error "invalid use of" } - try { } catch (auto *) { } // { dg-error "invalid use of" } + try { } catch (auto i) { } // { dg-error "parameter declared" } + try { } catch (auto) { } // { dg-error "parameter declared" } + try { } catch (auto *i) { } // { dg-error "parameter declared" } + try { } catch (auto *) { } // { dg-error "parameter declared" } } void