@@ -5576,11 +5576,18 @@ cp_parser_postfix_expression (cp_parser
/* Restore the old message. */
parser->type_definition_forbidden_message = saved_message;
+ bool saved_greater_than_is_operator_p
+ = parser->greater_than_is_operator_p;
+ parser->greater_than_is_operator_p = true;
+
/* And the expression which is being cast. */
cp_parser_require (parser, CPP_OPEN_PAREN, RT_OPEN_PAREN);
expression = cp_parser_expression (parser, /*cast_p=*/true, & idk);
cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN);
+ parser->greater_than_is_operator_p
+ = saved_greater_than_is_operator_p;
+
/* Only type conversions to integral or enumeration types
can be used in constant-expressions. */
if (!cast_valid_in_integral_constant_expression_p (type)
@@ -0,0 +1,8 @@
+// PR c++/57771
+// { dg-do compile }
+
+template <int N>
+struct S {};
+
+S <static_cast <int> (4>>2)> s1;
+S <reinterpret_cast <int> (4>>2)> s2;