c-lex.c (yylex): Don't allow integer suffixes 'LUL', 'Ll', 'lL'.
authorJoseph Myers <jsm28@cam.ac.uk>
Tue, 8 Aug 2000 08:23:31 +0000 (09:23 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Tue, 8 Aug 2000 08:23:31 +0000 (09:23 +0100)
* c-lex.c (yylex): Don't allow integer suffixes 'LUL', 'Ll', 'lL'.

testsuite:
* gcc.dg/noncompile/const-ll-1.c: New test.

From-SVN: r35563

gcc/ChangeLog
gcc/c-lex.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/noncompile/const-ll-1.c [new file with mode: 0644]

index 12609e2dcb62e3e8f3a4a9a4f92d2ac3ee5060dd..97453f04c05c9a02043eb189797a448e31e58f60 100644 (file)
@@ -1,3 +1,7 @@
+2000-08-08  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+       * c-lex.c (yylex): Don't allow integer suffixes 'LUL', 'Ll', 'lL'.
+
 2000-08-07  Nick Clifton  <nickc@redhat.com>
 
        * config/mips/mips.c: Fix compile time warning messages.
index 616ecbe2080491e97c9e2b59d31cd529d2e2698c..e0137e32ae01ad2cb0ae41887260b2ef3f6fc513 100644 (file)
@@ -1762,6 +1762,7 @@ yylex ()
            int spec_unsigned = 0;
            int spec_long = 0;
            int spec_long_long = 0;
+           int suffix_lu = 0;
            int spec_imag = 0;
            int warn = 0, i;
 
@@ -1773,6 +1774,8 @@ yylex ()
                    if (spec_unsigned)
                      error ("two `u's in integer constant");
                    spec_unsigned = 1;
+                   if (spec_long)
+                     suffix_lu = 1;
                  }
                else if (c == 'l' || c == 'L')
                  {
@@ -1780,12 +1783,16 @@ yylex ()
                      {
                        if (spec_long_long)
                          error ("three `l's in integer constant");
+                       else if (suffix_lu)
+                         error ("`LUL' is not a valid integer suffix");
+                       else if (c != spec_long)
+                         error ("`Ll' and `lL' are not valid integer suffixes");
                        else if (pedantic && ! flag_isoc99
                                 && ! in_system_header && warn_long_long)
                          pedwarn ("ANSI C forbids long long integer constants");
                        spec_long_long = 1;
                      }
-                   spec_long = 1;
+                   spec_long = c;
                  }
                else if (c == 'i' || c == 'j' || c == 'I' || c == 'J')
                  {
index f50a8de7c205e24ab2f5e99dfd560e1aa06fa0b1..febc005df0c39769d23da292f29be12f7fd5f5cf 100644 (file)
@@ -1,3 +1,7 @@
+2000-08-08  Joseph S. Myers  <jsm28@cam.ac.uk>
+
+       * gcc.dg/noncompile/const-ll-1.c: New test.
+
 2000-08-07  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * gcc.dg/c90-printf-2.c, gcc.dg/c99-printf-2.c: New tests.
diff --git a/gcc/testsuite/gcc.dg/noncompile/const-ll-1.c b/gcc/testsuite/gcc.dg/noncompile/const-ll-1.c
new file mode 100644 (file)
index 0000000..e38dff2
--- /dev/null
@@ -0,0 +1,24 @@
+/* Test for broken long long suffixes.  */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+
+/* The following are valid integer suffixes, according to C99:
+
+   no suffix
+   u or U
+   ul, uL, Ul or UL
+   ull, uLL, Ull or ULL
+   l or L
+   lu, lU, Lu or LU
+   llu, llU, LLu or LLU
+
+   The following are not but have been accepted by GCC in the past:
+
+   lul and case variants (the 'l's being separated by a 'u')
+   lL, Ll and variants with a 'u' (mixed case pair of 'l's)
+
+   (cpplib gets this right when processing #if expressions.)
+
+*/
+
+unsigned long long a = 1LUL; /* { dg-error "LUL" "error for LUL suffix" } */
+long long b = 1Ll; /* { dg-error "Ll" "error for Ll suffix" } */