This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] fix 31924, preprocessor misses invalid floating point suffixes
- From: Janis Johnson <janis187 at us dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 14 May 2007 15:31:32 -0700
- Subject: [PATCH] fix 31924, preprocessor misses invalid floating point suffixes
This patch allows the preprocessor to detect "fd" and "ld" as invalid
suffixes for floating point constants. Bootstrapped and regression
tested on powerpc64-linux, ok for mainline and, when it's open again,
the 4.2 branch?
2007-05-14 Janis Johnson <janis187@us.ibm.com>
libcpp/
PR c/31924
* expr.c (interpret_float_suffix): Check for invalid suffix.
gcc/testsuite/
PR c/31924
* gcc.dg/fltconst-1.c: New test.
Index: libcpp/expr.c
===================================================================
--- libcpp/expr.c (revision 124664)
+++ libcpp/expr.c (working copy)
@@ -87,16 +87,19 @@
while (len--)
switch (s[len])
{
- case 'f': case 'F': f++; break;
- case 'l': case 'L': l++; break;
+ case 'f': case 'F':
+ if (d > 0)
+ return 0;
+ f++;
+ break;
+ case 'l': case 'L':
+ if (d > 0)
+ return 0;
+ l++;
+ break;
case 'i': case 'I':
case 'j': case 'J': i++; break;
- case 'd': case 'D':
- /* Disallow fd, ld suffixes. */
- if (d && (f || l))
- return 0;
- d++;
- break;
+ case 'd': case 'D': d++; break;
default:
return 0;
}
Index: gcc/testsuite/gcc.dg/fltconst-1.c
===================================================================
--- gcc/testsuite/gcc.dg/fltconst-1.c (revision 0)
+++ gcc/testsuite/gcc.dg/fltconst-1.c (revision 0)
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+double a = 1.ld; /* { dg-error "invalid suffix" } */
+double b = 1.fd; /* { dg-error "invalid suffix" } */
+double c = 1.di; /* { dg-error "invalid suffix" } */
+double d = 1.dj; /* { dg-error "invalid suffix" } */
+double e = 1.id; /* { dg-error "invalid suffix" } */
+double f = 1.jd; /* { dg-error "invalid suffix" } */
+double g = 1.ddd; /* { dg-error "invalid suffix" } */
+double h = 1.ldd; /* { dg-error "invalid suffix" } */
+double i = 1.dld; /* { dg-error "invalid suffix" } */
+double j = 1.ddl; /* { dg-error "invalid suffix" } */
+double k = 1.fdd; /* { dg-error "invalid suffix" } */
+double l = 1.dfd; /* { dg-error "invalid suffix" } */
+double m = 1.ddf; /* { dg-error "invalid suffix" } */