bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

{Spam?} Fix clang compile warnings / gcc breakage with include_next


From: Michael Weiser
Subject: {Spam?} Fix clang compile warnings / gcc breakage with include_next
Date: Fri, 16 Jan 2015 17:57:03 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

Hi,

compiling bison 3.0.3 with gcc-4.0.1 (Apple Inc. build 5493) (latest
available on Mac OS X 10.5) fails with the following error:

  CC       lib/math.o
In file included from lib/math.h:27,
                 from lib/math.h:27,
[about a 100 repeats]
                 from lib/math.c:3:
lib/math.h:27:23: error: #include nested too deeply
make[2]: *** [lib/math.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

The cause is usage of #include_next in conjunction with #include
"math.h" (as opposed to #include <math.h>) and adding the lib
subdirectory to the search path via -Ilib. If either -Ilib is changed to
-I./lib or #include "math.h" to #include <math.h> the problem does away.
So this certainly seems to be some sort of bug in gcc.

I've created a small test case which reports the following with Apple's
gcc-4.0.1:

address@hidden ./test.sh 
compile command: gcc -c -o /dev/null -I./lib lib/math.c
math.c compiled fine with working cpp flags
compile command: gcc -c -o /dev/null -Ilib lib/math.c
In file included from lib/math.h:2,
                 from lib/math.h:2,
[about a 100 repeats]
                 from lib/math.h:2,
                 from lib/math.c:1:
lib/math.h:2:23: error: #include nested too deeply
math.c did not compile with broken cpp flags
compile command: gcc -c -o /dev/null -I./lib lib/math_path.c
math_path.c compiled fine with working cpp flags
compile command: gcc -c -o /dev/null -Ilib lib/math_path.c
math_path.c compiled fine with broken cpp flags

This seems to have been fixed in later versions of (Apple) gcc and also
doesn't happen with various versions of clang I've tried. Though clang
complains "./lib/math.h:2:2: warning: #include_next with absolute path"
when using #include "math.h" if the header does not contain "#pragma GCC
system_header".

So I'd like to suggest changing -Ilib to -I./lib as in the attached
patch to avoid this problem with older gccs.
-- 
Thanks,
Michael

Attachment: bison-3.0.3-gcc401-include_next.patch
Description: Text Data

Attachment: testcase.tar.gz
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]