This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for 'long long' integer constants
- To: gcc-patches at gcc dot gnu dot org
- Subject: Patch for 'long long' integer constants
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Tue, 8 Aug 2000 01:01:22 +0100 (BST)
GCC is overly lax in processing 'long long' integer suffixes. This
patch corrects this. cpplib is already correct in this regard.
Bootstrapped with no regressions on i686-pc-linux-gnu. OK to commit?
gcc/ChangeLog:
2000-08-07 Joseph S. Myers <jsm28@cam.ac.uk>
* c-lex.c (yylex): Don't allow integer suffixes 'LUL', 'Ll', 'lL.
gcc/testsuite/ChangeLog:
2000-08-07 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.dg/noncompile/const-ll-1.c: New test.
--- c-lex.c.orig Fri Aug 4 08:30:40 2000
+++ c-lex.c Mon Aug 7 20:26:18 2000
@@ -1762,6 +1762,7 @@
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 @@
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 @@
{
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')
{
--- gcc.dg/noncompile/const-ll-1.c.orig Fri Sep 11 11:31:59 1998
+++ gcc.dg/noncompile/const-ll-1.c Mon Aug 7 20:11:10 2000
@@ -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" } */
--
Joseph S. Myers
jsm28@cam.ac.uk