Hi,
in order to fix this parsing issue with '>' between square brackets, it
seems we have simply to use the parser->greater_than_is_operator_p
mechanism. Tested x86_64-linux.
Thanks,
Paolo.
PS: Even if the testcase uses a constexpr array I don't think we need to
special case c++11 vs c++98. Neither wrap only the cp_parser_expression
call.
///////////////////////
/cp
2013-10-15 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/58707
* parser.c (cp_parser_postfix_open_square_expression): Set
parser->greater_than_is_operator_p for the argument.
/testsuite
2013-10-15 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/58707
* g++.dg/cpp0x/pr58707.C: New.
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 203587)
+++ cp/parser.c (working copy)
@@ -6231,10 +6231,14 @@ cp_parser_postfix_open_square_expression (cp_parse
{
tree index = NULL_TREE;
location_t loc = cp_lexer_peek_token (parser->lexer)->location;
+ bool saved_greater_than_is_operator_p;
/* Consume the `[' token. */
cp_lexer_consume_token (parser->lexer);
+ saved_greater_than_is_operator_p = parser->greater_than_is_operator_p;
+ parser->greater_than_is_operator_p = true;
+
/* Parse the index expression. */
/* ??? For offsetof, there is a question of what to allow here. If
offsetof is not being used in an integral constant expression context,
@@ -6278,6 +6282,8 @@ cp_parser_postfix_open_square_expression (cp_parse
index = cp_parser_expression (parser, /*cast_p=*/false, NULL);
}
+ parser->greater_than_is_operator_p = saved_greater_than_is_operator_p;
+
/* Look for the closing `]'. */
cp_parser_require (parser, CPP_CLOSE_SQUARE, RT_CLOSE_SQUARE);
Index: testsuite/g++.dg/cpp0x/pr58707.C
===================================================================
--- testsuite/g++.dg/cpp0x/pr58707.C (revision 0)
+++ testsuite/g++.dg/cpp0x/pr58707.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/58707
+// { dg-do compile { target c++11 } }
+
+template<int i> class TC { };
+constexpr int foo[] = { 42 };
+TC<foo[0 > 1]> bar;