tf_warning_or_error);
}
-/* Returns 1 if TOKEN may start a cast-expression and, in C++11,
- isn't '[', -1 if TOKEN is '[' in C++11, 0 otherwise. */
+/* Returns 1 if TOKEN may start a cast-expression and isn't '++', '--',
+ neither '[' in C++11; -1 if TOKEN is '++', '--', or '[' in C++11;
+ 0 otherwise. */
static int
cp_parser_tokens_start_cast_expression (cp_parser *parser)
return cp_lexer_peek_nth_token (parser->lexer, 2)->type
!= CPP_CLOSE_PAREN;
+ case CPP_OPEN_SQUARE:
/* '[' may start a primary-expression in obj-c++ and in C++11,
as a lambda-expression, eg, '(void)[]{}'. */
- case CPP_OPEN_SQUARE:
if (cxx_dialect >= cxx11)
return -1;
return c_dialect_objc ();
+ case CPP_PLUS_PLUS:
+ case CPP_MINUS_MINUS:
+ /* '++' and '--' may or may not start a cast-expression:
+
+ struct T { void operator++(int); };
+ void f() { (T())++; }
+
+ vs
+
+ int a;
+ (int)++a; */
+ return -1;
+
default:
return 1;
}
function returning T. */
if (!cp_parser_error_occurred (parser))
{
- /* Only commit if the cast-expression doesn't start with '[' in
- C++11, which may or may not start a lambda-expression. */
+ /* Only commit if the cast-expression doesn't start with
+ '++', '--', or '[' in C++11. */
if (cast_expression > 0)
cp_parser_commit_to_topmost_tentative_parse (parser);
+2014-07-17 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/61804
+ * g++.dg/parse/pr61804.C: New.
+
2014-07-16 Arnaud Charlet <charlet@adacore.com>
* gnat.db/specs/alignment2.ads, gnat.db/specs/size_clause1.ads,