From: Mark Mitchell Date: Tue, 13 Sep 2005 02:41:07 +0000 (+0000) Subject: re PR c++/23841 (Floating-point literals cast to integral types should be accepted... X-Git-Tag: misc/cutover-cvs2svn~654 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=060e73279b91815dba57658f6486f07285c2db0a;p=thirdparty%2Fgcc.git re PR c++/23841 (Floating-point literals cast to integral types should be accepted in integer constant expressions) PR c++/23841 * parser.c (cp_parser_primary_expression): Recognize the closing ">" of a template-argument-list after a floating-point literal as the end of a cast expression. PR c++/23841 * g++.dg/parse/template17.C: New test. From-SVN: r104208 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 6ce6f5fd1f78..cd19181dafc0 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2005-09-12 Mark Mitchell + + PR c++/23841 + * parser.c (cp_parser_primary_expression): Recognize the closing + ">" of a template-argument-list after a floating-point literal as + the end of a cast expression. + 2005-09-12 Mark Mitchell PR c++/23789 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a8a2c4963e7b..0f8d17cd5040 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -2779,7 +2779,10 @@ cp_parser_primary_expression (cp_parser *parser, /* The end of the cast-expression. */ && next_token->type != CPP_CLOSE_PAREN /* The end of an array bound. */ - && next_token->type != CPP_CLOSE_SQUARE) + && next_token->type != CPP_CLOSE_SQUARE + /* The closing ">" in a template-argument-list. */ + && (next_token->type != CPP_GREATER + || parser->greater_than_is_operator_p)) cast_p = false; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9678760d8a65..26919da7139c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-09-12 Mark Mitchell + + PR c++/23841 + * g++.dg/parse/template17.C: New test. + 2005-09-12 Mark Mitchell PR c++/23789 diff --git a/gcc/testsuite/g++.dg/parse/template17.C b/gcc/testsuite/g++.dg/parse/template17.C new file mode 100644 index 000000000000..ade598d39e1b --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/template17.C @@ -0,0 +1,13 @@ +// PR c++/23841 + +template +struct S +{ + int f(int i = I) { return i; } +}; + +void +g () +{ + S<(int)0.> a2; +}