This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] warn about decimal float suffixes with -pedantic


This patch causes gcc to warn about the use of decimal float constants
(those ending in "df", "dd", and "dl") with use of -pedantic.

Bootstrapped and regression tested on powerpc64-linux, OK for mainline?

2007-05-14  Janis Johnson  <janis187@us.ibm.com>

libcpp/
        * expr.c (cpp_classify_number): Warn about dfp constant for -pedantic.
gcc/testsuite/
        * gcc.dg/fltconst-pedantic-dfp.c: New test.

Index: libcpp/expr.c
===================================================================
--- libcpp/expr.c	(revision 124664)
+++ libcpp/expr.c	(working copy)
@@ -270,6 +273,10 @@
           return CPP_N_INVALID;
         }
 
+      if ((result & CPP_N_DFLOAT) && CPP_PEDANTIC (pfile))
+	cpp_error (pfile, CPP_DL_PEDWARN,
+		   "decimal float constants are a GCC extension");
+
       result |= CPP_N_FLOATING;
     }
   else
Index: gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c
===================================================================
--- gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c	(revision 0)
+++ gcc/testsuite/gcc.dg/fltconst-pedantic-dfp.c	(revision 0)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-pedantic" } */
+
+double a = 1.dl;	/* { dg-warning "decimal float" } */
+double b = 1.df;	/* { dg-warning "decimal float" } */
+double c = 1.dd;	/* { dg-warning "decimal float" } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]