re PR c++/51908 ([C++11] ICE in cp_parser_abort_tentative_parse with decltype and...
[gcc.git] / gcc / cp / parser.c
index 061b5714790e5910add0c23223ecd1aa20d1ef70..dfeeb0a94c28d2fcf01aff11b212fd6d09381023 100644 (file)
@@ -5546,6 +5546,7 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
        tree type;
        tree expression;
        const char *saved_message;
+       bool saved_in_type_id_in_expr_p;
 
        /* All of these can be handled in the same way from the point
           of view of parsing.  Begin by consuming the token
@@ -5560,7 +5561,10 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
        /* Look for the opening `<'.  */
        cp_parser_require (parser, CPP_LESS, RT_LESS);
        /* Parse the type to which we are casting.  */
+       saved_in_type_id_in_expr_p = parser->in_type_id_in_expr_p;
+       parser->in_type_id_in_expr_p = true;
        type = cp_parser_type_id (parser);
+       parser->in_type_id_in_expr_p = saved_in_type_id_in_expr_p;
        /* Look for the closing `>'.  */
        cp_parser_require (parser, CPP_GREATER, RT_GREATER);
        /* Restore the old message.  */