This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: long long constants and -Wno-long-long
- To: egcs-patches at cygnus dot com
- Subject: PATCH: long long constants and -Wno-long-long
- From: Nathan Sidwell <nathan at cs dot bris dot ac dot uk>
- Date: Fri, 21 Aug 1998 19:38:22 +0100
- Organization: Computer Science Dept, Bristol University
Hi,
Currently both gcc and g++ warn about long long constants when in -ansi
-pedantic mode, even when the -Wno-long-long flag is given. This does
not appear to be the expected behaviour. -Wno-long-long explicitly
permits variables of type long long, even in pedantic mode. Therefore I
think the same flag should allow long long literals too. Attached is a
patch to both c-lex.c and cp/lex.c to fix the problem for both C and
C++. Here is a test case, (suitable for both C and C++)
compile with
g++ -ansi -pedantic -Wno-long-long
gcc -ansi -pedantic -Wno-long-long
--begin longlong.ii
void foo()
{
long long t;
t = 32ll;
}
--end longlong.ii
cheers,
nathan
--
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
You can up the bandwidth, but you can't up the speed of light
nathan@acm.org http://www.cs.bris.ac.uk/~nathan/ nathan@cs.bris.ac.uk
ChangeLog entry (for gcc/ChangeLog)
Fri Aug 21 19:23:00 BST 1998 Nathan Sidwell <nathan@acm.org>
* c-lex.c (real_yylex): Don't warn about long long constants if
we're allowing long long
ChangeLog entry (for gcc/cp/ChangeLog)
Fri Aug 21 19:23:00 BST 1998 Nathan Sidwell <nathan@acm.org>
* lex.c (real_yylex): Don't warn about long long constants if
we're allowing long long
Index: gcc/c-lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/c-lex.c,v
retrieving revision 1.26
diff -b -c -3 -p -r1.26 c-lex.c
*** c-lex.c 1998/07/06 21:53:20 1.26
--- c-lex.c 1998/08/21 18:36:07
*************** yylex ()
*** 1623,1629 ****
{
if (spec_long_long)
error ("three `l's in integer constant");
! else if (pedantic)
pedwarn ("ANSI C forbids long long integer constants");
spec_long_long = 1;
}
--- 1623,1629 ----
{
if (spec_long_long)
error ("three `l's in integer constant");
! else if (pedantic && ! in_system_header && warn_long_long)
pedwarn ("ANSI C forbids long long integer constants");
spec_long_long = 1;
}
Index: gcc/cp/lex.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/lex.c,v
retrieving revision 1.54.2.3
diff -b -c -3 -p -r1.54.2.3 lex.c
*** lex.c 1998/07/20 00:19:18 1.54.2.3
--- lex.c 1998/08/21 18:36:10
*************** real_yylex ()
*** 3808,3814 ****
{
if (spec_long_long)
error ("three `l's in integer constant");
! else if (pedantic)
pedwarn ("ANSI C++ forbids long long integer constants");
spec_long_long = 1;
}
--- 3808,3814 ----
{
if (spec_long_long)
error ("three `l's in integer constant");
! else if (pedantic && ! in_system_header && warn_long_long)
pedwarn ("ANSI C++ forbids long long integer constants");
spec_long_long = 1;
}