]> git.ipfire.org Git - thirdparty/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 12:06:31 +0000 (14:06 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 26 Oct 2007 12:06:31 +0000 (14:06 +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: r129650

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

index 02af49f8d39be07b1ad14866d1307fa95fabf73e..85e439bd78614f83f405d1af6d62a8f26942bb23 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-08-31  Paolo Carlini  <pcarlini@suse.de>
 
        PR c++/32113
index fdc60347f802fc35190c7dabf260f03dfcb1d31e..63566c0972de49368311e554a8900716f05a96b7 100644 (file)
@@ -4700,6 +4700,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)
@@ -4708,6 +4709,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)
@@ -4781,9 +4788,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 616a84a65da87e7c88702f86e3486bc19657a42d..3cfa69ee1353c7be3d22534884d845373e83297b 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-09-06  David Daney  <ddaney@avtrex.com>
            Richard Sandiford  <richard@codesourcery.com>
 
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;
+}