re PR c++/55080 (-pedantic produces error: floating-point literal cannot appear in...
authorPaolo Carlini <paolo.carlini@oracle.com>
Thu, 17 Nov 2016 21:44:05 +0000 (21:44 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Thu, 17 Nov 2016 21:44:05 +0000 (21:44 +0000)
/cp
2016-11-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/55080
* parser.c (cp_parser_non_integral_constant_expression): Issue a
pedwarn instead of an error for case NIC_FLOAT.

/testsuite
2016-11-17  Paolo Carlini  <paolo.carlini@oracle.com>

PR c++/55080
* g++.dg/parse/pr55080.C: New.

From-SVN: r242565

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/pr55080.C [new file with mode: 0644]

index 24564ecfaa6b2bbd1da68b7d930f120e7954273e..3178c1f1c4d06784545715fbafd9b77427c4eb2c 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/55080
+       * parser.c (cp_parser_non_integral_constant_expression): Issue a
+       pedwarn instead of an error for case NIC_FLOAT.
+
 2016-11-17  Jason Merrill  <jason@redhat.com>
 
        PR c++/78124 - list-initialization and inherited ctor
index 3ab0b68653280d4d0864f2557627b2000c551319..9da4b30f656c3c2258e545966b3606c84623a3ce 100644 (file)
@@ -3028,8 +3028,9 @@ cp_parser_non_integral_constant_expression (cp_parser  *parser,
          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 8018587479a520779d112e5b7bda733480599148..ed6b9a72bac7da7597876897d4cb2f8b159b421b 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-17  Paolo Carlini  <paolo.carlini@oracle.com>
+
+       PR c++/55080
+       * g++.dg/parse/pr55080.C: New.
+
 2016-11-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/78101
diff --git a/gcc/testsuite/g++.dg/parse/pr55080.C b/gcc/testsuite/g++.dg/parse/pr55080.C
new file mode 100644 (file)
index 0000000..b66395a
--- /dev/null
@@ -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" }
+};