diff options
author | Ville Voutilainen <ville.voutilainen@gmail.com> | 2015-04-20 23:44:25 +0300 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2015-04-20 16:44:25 -0400 |
commit | 0cfabb3780b23de06e8fd52bfe15b2aea7b56f42 (patch) | |
tree | 42719c0d52a2a7f32a6f1e3f3746d5a33db3bf17 | |
parent | cb864fbc7ef9d589056f876dfbf26101ba6c53d6 (diff) | |
download | gcc-0cfabb3780b23de06e8fd52bfe15b2aea7b56f42.zip gcc-0cfabb3780b23de06e8fd52bfe15b2aea7b56f42.tar.gz gcc-0cfabb3780b23de06e8fd52bfe15b2aea7b56f42.tar.bz2 |
Reject trailing return type for an operator auto().
* decl.c (grokdeclarator): Reject trailing return types for
all conversion operators, don't handle conversion operators
in the previous checks that deal with auto.
From-SVN: r222248
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/decl.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/auto9.C | 4 |
3 files changed, 14 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 08d1010..f7da7c6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2015-04-20 Ville Voutilainen <ville.voutilainen@gmail.com> + + Reject trailing return type for an operator auto(). + * decl.c (grokdeclarator): Reject trailing return types for + all conversion operators, don't handle conversion operators + in the previous checks that deal with auto. + 2015-04-20 Ilya Verbin <ilya.verbin@intel.com> * parser.c (cp_parser_omp_target_update): Add missed %> to error_at (). diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b920fe7..29d6e73 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9782,7 +9782,7 @@ grokdeclarator (const cp_declarator *declarator, virtualp = false; } } - else if (!is_auto (type)) + else if (!is_auto (type) && sfk != sfk_conversion) { error ("%qs function with trailing return type has" " %qT as its type rather than plain %<auto%>", @@ -9790,7 +9790,8 @@ grokdeclarator (const cp_declarator *declarator, return error_mark_node; } } - else if (declarator->u.function.late_return_type) + else if (declarator->u.function.late_return_type + && sfk != sfk_conversion) { if (cxx_dialect < cxx11) /* Not using maybe_warn_cpp0x because this should @@ -9899,6 +9900,8 @@ grokdeclarator (const cp_declarator *declarator, maybe_warn_cpp0x (CPP0X_EXPLICIT_CONVERSION); explicitp = 2; } + if (late_return_type_p) + error ("a conversion function cannot have a trailing return type"); } arg_types = grokparms (declarator->u.function.parameters, diff --git a/gcc/testsuite/g++.dg/cpp0x/auto9.C b/gcc/testsuite/g++.dg/cpp0x/auto9.C index 0c0f39f..83efbaa 100644 --- a/gcc/testsuite/g++.dg/cpp0x/auto9.C +++ b/gcc/testsuite/g++.dg/cpp0x/auto9.C @@ -21,8 +21,8 @@ struct A struct A2 { - operator auto () -> int; // { dg-error "invalid use of" "" { target { ! c++14 } } } - operator auto *() -> int; // { dg-error "auto" } + operator auto () -> int; // { dg-error "invalid use of|trailing return type" } + operator auto*() -> int; // { dg-error "invalid use of|trailing return type" } }; template <typename> struct B |