re PR c++/57771 (g++ misinterprets >> in static_cast)
authorJakub Jelinek <jakub@redhat.com>
Wed, 3 Jul 2013 20:20:30 +0000 (22:20 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 3 Jul 2013 20:20:30 +0000 (22:20 +0200)
PR c++/57771
* parser.c (cp_parser_postfix_expression) <case RID_STATCAST>
Temporarily set parser->greater_than_is_operator_p for
cp_parser_expression and restore from saved value afterwards.

* g++.dg/template/arg9.C: New test.

From-SVN: r200647

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/arg9.C [new file with mode: 0644]

index 2de63c0b8d87ef8cd9dbf0774541d33f3b5969a5..92fefea845cb3ccb2370084d2a172a1506decf2b 100644 (file)
@@ -1,3 +1,10 @@
+2013-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/57771
+       * parser.c (cp_parser_postfix_expression) <case RID_STATCAST>
+       Temporarily set parser->greater_than_is_operator_p for
+       cp_parser_expression and restore from saved value afterwards.
+
 2013-06-28  Ed Smith-Rowland  <3dw4rd@verizon.net>
 
        * cp-tree.h (UDLIT_OP_ANSI_PREFIX): Remove space.
index 6e8293b024e108a64d34b23d9894e92e0efcd79b..46a8deb588fe5ae2b6a189649ef9b3b800e81c1c 100644 (file)
@@ -5576,11 +5576,18 @@ cp_parser_postfix_expression (cp_parser *parser, bool address_p, bool cast_p,
        /* 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)
index e0c5efcba49fa5d6b5dd1a111a77097c2eead624..410bc213b23dcea142c654c6b0269871f50c0b3b 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/57771
+       * g++.dg/template/arg9.C: New test.
+
 2013-07-02  Sriraman Tallam  <tmsriram@google.com>
 
        * gcc.target/i386/avx-inline.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/arg9.C b/gcc/testsuite/g++.dg/template/arg9.C
new file mode 100644 (file)
index 0000000..41af114
--- /dev/null
@@ -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;