From 0f1e332126d1a3bc3c6048bad324049b9f423020 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 26 Oct 2007 13:57:46 +0200 Subject: [PATCH] re PR c++/33744 (function-style cast and '>' not allowed in template argument) 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 | 6 ++++++ gcc/cp/parser.c | 16 +++++++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/template/arg6.C | 15 +++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/arg6.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e345e75bf2d..cabde879e8f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2007-10-26 Jakub Jelinek + + 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 PR c++/31747 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 8e48b1693d3..0b94375d358 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 17252b2ee8a..0293ed0bdac 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-10-26 Jakub Jelinek + + PR c++/33744 + * g++.dg/template/arg6.C: New test. + 2007-10-26 Paolo Carlini 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 index 00000000000..ef05abaeeda --- /dev/null +++ b/gcc/testsuite/g++.dg/template/arg6.C @@ -0,0 +1,15 @@ +// PR c++/33744 +// { dg-do run } + +template struct A { bool b; A() : b(B) {}; }; +A a; +A b; +A<(bool)(2>1)> c; +A1))> d; +A1)> e; + +int +main () +{ + return (a.b && b.b && c.b && d.b && e.b) ? 0 : 1; +} -- 2.30.2