From 80557bb787a65fb5b7a65d14ccabe6e962f88079 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Thu, 17 Nov 2016 21:44:05 +0000 Subject: [PATCH] re PR c++/55080 (-pedantic produces error: floating-point literal cannot appear in a constant-expression) /cp 2016-11-17 Paolo Carlini 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 PR c++/55080 * g++.dg/parse/pr55080.C: New. From-SVN: r242565 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 5 +++-- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/parse/pr55080.C | 6 ++++++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/parse/pr55080.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 24564ecfaa6..3178c1f1c4d 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-11-17 Paolo Carlini + + 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 PR c++/78124 - list-initialization and inherited ctor diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 3ab0b686532..9da4b30f656 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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 " diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8018587479a..ed6b9a72bac 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-17 Paolo Carlini + + PR c++/55080 + * g++.dg/parse/pr55080.C: New. + 2016-11-17 Michael Meissner 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 index 00000000000..b66395a11d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/parse/pr55080.C @@ -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" } +}; -- 2.11.4.GIT