aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>2002-10-05 12:28:16 +0000
committerKriang Lerdsuwanakij <lerdsuwa@gcc.gnu.org>2002-10-05 12:28:16 +0000
commiteb55ce4b2f1fdaa259518de829d04c7e8855185f (patch)
tree01de7251b305aa971ce9ce8b121339df1f03039b
parentf5b63cb6d7bb6b742d69f428cc80d60a93f45b3a (diff)
downloadgcc-eb55ce4b2f1fdaa259518de829d04c7e8855185f.zip
gcc-eb55ce4b2f1fdaa259518de829d04c7e8855185f.tar.gz
gcc-eb55ce4b2f1fdaa259518de829d04c7e8855185f.tar.bz2
re PR c++/7804 (bad printing of fp constant in warning message)
PR c++/7804 * error.c (dump_expr) [REAL_CST]: Output in decimal format. * g++.dg/other/warning1.C: New test. From-SVN: r57843
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/error.c8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/other/warning1.C18
4 files changed, 29 insertions, 7 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 78ffd60f..e32c516 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2002-10-05 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/7804
+ * error.c (dump_expr) [REAL_CST]: Output in decimal format.
+
2002-10-03 Mark Mitchell <mark@codesourcery.com>
PR c++/7931
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 7d270b2..314cf70 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1508,13 +1508,7 @@ dump_expr (t, flags)
break;
case REAL_CST:
- {
- const unsigned char *p = (const unsigned char *) &TREE_REAL_CST (t);
- size_t i;
- strcpy (digit_buffer, "0x");
- for (i = 0; i < sizeof TREE_REAL_CST (t); i++)
- sprintf (digit_buffer + 2 + 2*i, "%02x", *p++);
- }
+ REAL_VALUE_TO_DECIMAL (TREE_REAL_CST (t), digit_buffer, -1);
output_add_string (scratch_buffer, digit_buffer);
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e3e11ed..f5cfa35 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2002-10-05 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
+
+ PR c++/7804
+ * g++.dg/other/warning1.C: New test.
+
2002-10-04 Roger Sayle <roger@eyesopen.com>
* gcc.c-torture/execute/20020720-1.x: XFAIL instead of skipping
diff --git a/gcc/testsuite/g++.dg/other/warning1.C b/gcc/testsuite/g++.dg/other/warning1.C
new file mode 100644
index 0000000..109fc46
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/warning1.C
@@ -0,0 +1,18 @@
+// { dg-do compile }
+
+// PR c++/7804
+// Floating point formatting in error and warning messages
+
+extern "C" int printf(const char *, ...);
+
+struct S
+{
+ static const float inf = 1.0f / 0.0f; // { dg-warning "1.0|initialization" }
+ static const float nan = 0.0f / 0.0f; // { dg-warning "0.0|initialization" }
+};
+
+int main()
+{
+ printf("%f\n%f\n", S::inf, S::nan);
+ return 0;
+}