... oops, forgot about parser->non_integral_constant_expression_p. The
version below, which I'm currently regtesting again, seems more correct.
Thanks,
Paolo.
///////////////////
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 242540)
+++ cp/parser.c (working copy)
@@ -4841,7 +4841,13 @@ cp_parser_primary_expression (cp_parser *parser,
checked at that point. If we are not within a cast, then
this code is invalid. */
if (!cast_p)
- cp_parser_non_integral_constant_expression (parser, NIC_FLOAT);
+ {
+ parser->non_integral_constant_expression_p = true;
+ if (!parser->allow_non_integral_constant_expression_p)
+ pedwarn (input_location, OPT_Wpedantic,
+ "ISO C++ forbids using a floating-point literal "
+ "in a constant-expression");
+ }
}
return cp_expr (token->u.value, token->location);
Index: testsuite/g++.dg/parse/pr55080.C
===================================================================
--- testsuite/g++.dg/parse/pr55080.C (revision 0)
+++ testsuite/g++.dg/parse/pr55080.C (working copy)
@@ -0,0 +1,6 @@
+// PR c++/55080
+// { dg-options "-std=c++98 -pedantic" }
+
+class B {
+ static const int c = 3.1415926; // { dg-warning "constant-expression" }
+};