]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/33744 (function-style cast and '>' not allowed in template argument)
authorJakub Jelinek <jakub@redhat.com>
Fri, 26 Oct 2007 11:57:46 +0000 (13:57 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 26 Oct 2007 11:57:46 +0000 (13:57 +0200)
PR c++/33744
* parser.c (cp_parser_parenthesized_expression_list): Set
greater_than_is_operator_p to true in between the parens.

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

From-SVN: r129648

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

index e345e75bf2d532aab9b06c846ad44dc0de275bb0..cabde879e8fddb5a6407109573e03d0977547178 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33744
+       * parser.c (cp_parser_parenthesized_expression_list): Set
+       greater_than_is_operator_p to true in between the parens.
+
 2007-10-26  Paolo Carlini  <pcarlini@suse.de>
 
        PR c++/31747
index 8e48b1693d3810a87e5edb250e2c051cf448a473..0b94375d358a92d191e79796b4ae9d0a0082e1f4 100644 (file)
@@ -4976,6 +4976,7 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
   tree expression_list = NULL_TREE;
   bool fold_expr_p = is_attribute_list;
   tree identifier = NULL_TREE;
+  bool saved_greater_than_is_operator_p;
 
   /* Assume all the expressions will be constant.  */
   if (non_constant_p)
@@ -4984,6 +4985,12 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
   if (!cp_parser_require (parser, CPP_OPEN_PAREN, "`('"))
     return error_mark_node;
 
+  /* Within a parenthesized expression, a `>' token is always
+     the greater-than operator.  */
+  saved_greater_than_is_operator_p
+    = parser->greater_than_is_operator_p;
+  parser->greater_than_is_operator_p = true;
+
   /* Consume expressions until there are no more.  */
   if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_PAREN))
     while (true)
@@ -5069,9 +5076,16 @@ cp_parser_parenthesized_expression_list (cp_parser* parser,
       if (ending < 0)
        goto get_comma;
       if (!ending)
-       return error_mark_node;
+       {
+         parser->greater_than_is_operator_p
+           = saved_greater_than_is_operator_p;
+         return error_mark_node;
+       }
     }
 
+  parser->greater_than_is_operator_p
+    = saved_greater_than_is_operator_p;
+
   /* We built up the list in reverse order so we must reverse it now.  */
   expression_list = nreverse (expression_list);
   if (identifier)
index 17252b2ee8ad3ec0321108837188a3b10811ab02..0293ed0bdac9e4fa23023803d04ae1d9be3c4f89 100644 (file)
@@ -1,3 +1,8 @@
+2007-10-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33744
+       * g++.dg/template/arg6.C: New test.
+
 2007-10-26  Paolo Carlini  <pcarlini@suse.de>
 
        PR c++/31747
diff --git a/gcc/testsuite/g++.dg/template/arg6.C b/gcc/testsuite/g++.dg/template/arg6.C
new file mode 100644 (file)
index 0000000..ef05aba
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/33744
+// { dg-do run }
+
+template <bool B> struct A { bool b; A() : b(B) {}; };
+A<bool(1)> a;
+A<bool(1<2)> b;
+A<(bool)(2>1)> c;
+A<bool((2>1))> d;
+A<bool(2>1)> e;
+
+int
+main ()
+{
+  return (a.b && b.b && c.b && d.b && e.b) ? 0 : 1;
+}
This page took 0.149211 seconds and 5 git commands to generate.