aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2005-09-13 02:41:07 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2005-09-13 02:41:07 +0000
commit060e73279b91815dba57658f6486f07285c2db0a (patch)
treefc99a0d78145c65e69d008148fb60b154f63ef6a /gcc
parent2eef28ec7b537993d69c38797a6afd2b43a9e62c (diff)
downloadgcc-060e73279b91815dba57658f6486f07285c2db0a.zip
gcc-060e73279b91815dba57658f6486f07285c2db0a.tar.gz
gcc-060e73279b91815dba57658f6486f07285c2db0a.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/parser.c5
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/parse/template17.C13
4 files changed, 29 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6ce6f5f..cd19181 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2005-09-12 Mark Mitchell <mark@codesourcery.com>
+ 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 <mark@codesourcery.com>
+
PR c++/23789
* cvt.c (perform_qualification_conversions): Don't create
unnecessary NOP_EXPRs.
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index a8a2c49..0f8d17c 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 9678760..26919da 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2005-09-12 Mark Mitchell <mark@codesourcery.com>
+ PR c++/23841
+ * g++.dg/parse/template17.C: New test.
+
+2005-09-12 Mark Mitchell <mark@codesourcery.com>
+
PR c++/23789
* g++.dg/template/nontype14.C: New test.
diff --git a/gcc/testsuite/g++.dg/parse/template17.C b/gcc/testsuite/g++.dg/parse/template17.C
new file mode 100644
index 0000000..ade598d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/template17.C
@@ -0,0 +1,13 @@
+// PR c++/23841
+
+template <int I>
+struct S
+{
+ int f(int i = I) { return i; }
+};
+
+void
+g ()
+{
+ S<(int)0.> a2;
+}