aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-03-07 15:00:36 -0500
committerJason Merrill <jason@gcc.gnu.org>2014-03-07 15:00:36 -0500
commit968b3503744d250ed8980faf2d37143ad51fb7c8 (patch)
tree36619156fdc929f43514d2249f144bec423a1c74
parentd08a068b5e0d964152ee22435567c5279ada25ed (diff)
downloadgcc-968b3503744d250ed8980faf2d37143ad51fb7c8.zip
gcc-968b3503744d250ed8980faf2d37143ad51fb7c8.tar.gz
gcc-968b3503744d250ed8980faf2d37143ad51fb7c8.tar.bz2
parser.c (cp_parser_type_id_1): Only allow 'auto' in C++1y if we're in a trailing return type.
* parser.c (cp_parser_type_id_1): Only allow 'auto' in C++1y if we're in a trailing return type. From-SVN: r208415
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/parser.c4
-rw-r--r--gcc/testsuite/g++.dg/cpp1y/pr59110.C2
3 files changed, 7 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 99a71fb..140f53e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2014-03-07 Jason Merrill <jason@redhat.com>
+ * parser.c (cp_parser_type_id_1): Only allow 'auto' in C++1y if
+ we're in a trailing return type.
+
* typeck.c (comp_template_parms_position): 'auto' and
'decltype(auto)' are different from real template parms.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 71a2a9e..5725283 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -17992,7 +17992,9 @@ cp_parser_type_id_1 (cp_parser* parser, bool is_template_arg,
abstract_declarator = NULL;
if (type_specifier_seq.type
- && cxx_dialect < cxx1y
+ /* None of the valid uses of 'auto' in C++14 involve the type-id
+ nonterminal, but it is valid in a trailing-return-type. */
+ && !(cxx_dialect >= cxx1y && is_trailing_return)
&& type_uses_auto (type_specifier_seq.type))
{
/* A type-id with type 'auto' is only ok if the abstract declarator
diff --git a/gcc/testsuite/g++.dg/cpp1y/pr59110.C b/gcc/testsuite/g++.dg/cpp1y/pr59110.C
index dbbfa9b..5c9c208 100644
--- a/gcc/testsuite/g++.dg/cpp1y/pr59110.C
+++ b/gcc/testsuite/g++.dg/cpp1y/pr59110.C
@@ -1,4 +1,4 @@
// PR c++/59110
// { dg-options "-std=c++1y" }
-int i = *(auto*)0; // { dg-error "cannot convert" }
+int i = *(auto*)0; // { dg-error "" }