Hi,

On 17/11/2016 18:14, Jason Merrill wrote:
How about changing cp_parser_non_integral_constant_expression to issue
a pedwarn instead of error for NIC_FLOAT?
Indeed. And a relevant observation is that we don't pass NIC_FLOAT from anywhere else in the parser, please correct me if I'm wrong. The below is finishing testing, all good so far.

Thanks,
Paolo.

////////////////
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 242540)
+++ cp/parser.c (working copy)
@@ -3028,8 +3028,9 @@ cp_parser_non_integral_constant_expression (cp_par
          switch (thing)
            {
              case NIC_FLOAT:
-               error ("floating-point literal "
-                      "cannot appear in a constant-expression");
+               pedwarn (input_location, OPT_Wpedantic,
+                        "ISO C++ forbids using a floating-point literal "
+                        "in a constant-expression");
                return true;
              case NIC_CAST:
                error ("a cast to a type other than an integral or "
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" }
+};

Reply via email to