]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/31924 (gcc accepts invalid suffixes for decimal float constants)
authorJanis Johnson <janis187@us.ibm.com>
Mon, 14 May 2007 23:43:07 +0000 (23:43 +0000)
committerJanis Johnson <janis@gcc.gnu.org>
Mon, 14 May 2007 23:43:07 +0000 (23:43 +0000)
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.

From-SVN: r124730

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/fltconst-1.c [new file with mode: 0644]
libcpp/ChangeLog
libcpp/expr.c

index c5eb928acd748d2f966a121f54caf671a0c9a5e3..b195815eda09517df3cbad2d384e7f8d6ebf8bad 100644 (file)
@@ -1,5 +1,8 @@
 2007-05-14  Janis Johnson  <janis187@us.ibm.com>
 
+       PR c/31924
+       * gcc.dg/fltconst-1.c: New test.
+
        * gcc.dg/dfp/func-mixed.c: Replace invalid constant suffixes.
        * gcc.dg/dfp/operator-assignment.c: Ditto.
 
diff --git a/gcc/testsuite/gcc.dg/fltconst-1.c b/gcc/testsuite/gcc.dg/fltconst-1.c
new file mode 100644 (file)
index 0000000..bf92227
--- /dev/null
@@ -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" } */
index cc5a71692c70d10d6e1a370465ad2f7188fc1cd3..5b941ff9cca78c6bd5b7126a2a2c391b2b4944a2 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-14  Janis Johnson  <janis187@us.ibm.com>
+
+       PR c/31924
+       * expr.c (interpret_float_suffix): Check for invalid suffix.
+
 2007-05-02  Eric Christopher  <echristo@apple.com>
 
        * expr.c (num_div_op): Don't overflow if the result is
index a00614026c2e4fc8bd8f22293edaa81117e3f64a..8401daee032f24cb655766cc4b92f9948c64ced7 100644 (file)
@@ -87,16 +87,19 @@ interpret_float_suffix (const uchar *s, size_t len)
   while (len--)
     switch (s[len])
       {
-      case 'f': case 'F': f++; break;
-      case 'l': case 'L': l++; break;
-      case 'i': case 'I':
-      case 'j': case 'J': i++; break;
-      case 'd': case 'D':
-       /* Disallow fd, ld suffixes.  */
-       if (d && (f || l))
+      case 'f': case 'F':
+       if (d > 0)
+         return 0;
+       f++;
+       break;
+      case 'l': case 'L':
+       if (d > 0)
          return 0;
-       d++;
+       l++;
        break;
+      case 'i': case 'I':
+      case 'j': case 'J': i++; break;
+      case 'd': case 'D': d++; break;
       default:
        return 0;
       }