Bug 53463 - [4.8 Regression]: system header not recognized, yielding warnings about long long preprocessor constant
Summary: [4.8 Regression]: system header not recognized, yielding warnings about long ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: preprocessor (show other bugs)
Version: 4.8.0
: P3 normal
Target Milestone: 4.8.0
Assignee: Dodji Seketeli
URL:
Keywords: diagnostic, rejects-valid
Depends on:
Blocks:
 
Reported: 2012-05-23 20:15 UTC by Hans-Peter Nilsson
Modified: 2012-06-05 08:29 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: cris-axis-elf
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-05-25 00:00:00


Attachments
First test-case failing, preprocessed. (2.52 KB, text/plain)
2012-05-23 20:15 UTC, Hans-Peter Nilsson
Details
The offending system header _default_types.h, fresh from newlib. (753 bytes, text/plain)
2012-05-23 20:21 UTC, Hans-Peter Nilsson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hans-Peter Nilsson 2012-05-23 20:15:34 UTC
Created attachment 27483 [details]
First test-case failing, preprocessed.

These below tests previously passed, now they fails.
The svn revision r187587 exposed or caused these regressions.  Since then they fail as follows:

Running /tmp/bad0516b/gcc/gcc/testsuite/gcc.dg/cpp/cpp.exp ...
FAIL: gcc.dg/cpp/19990407-1.c (test for excess errors)
WARNING: gcc.dg/cpp/19990407-1.c compilation failed to produce executable
FAIL: gcc.dg/cpp/paste12.c (test for excess errors)
FAIL: gcc.dg/cpp/strp1.c (test for excess errors)
WARNING: gcc.dg/cpp/strp1.c compilation failed to produce executable
FAIL: gcc.dg/cpp/strp2.c (test for excess errors)
WARNING: gcc.dg/cpp/strp2.c compilation failed to produce executable
...
Running /tmp/bad0516b/gcc/gcc/testsuite/gcc.dg/dg.exp ...
...
FAIL: gcc.dg/struct-ret-libc.c (test for excess errors)
WARNING: gcc.dg/struct-ret-libc.c compilation failed to produce executable
...
Running /tmp/bad0516b/gcc/gcc/testsuite/g++.dg/dg.exp ...
...
FAIL: g++.dg/warn/format1.C -std=gnu++98 (test for excess errors)
FAIL: g++.dg/warn/format1.C -std=gnu++11 (test for excess errors)
FAIL: g++.dg/warn/huge-val1.C -std=gnu++98 (test for excess errors)
...
Running /tmp/bad0516b/gcc/gcc/testsuite/gfortran.dg/dg.exp ...
FAIL: gfortran.dg/bind_c_usage_16.f03  -O0  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_16.f03  -O0  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_16.f03  -O1  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_16.f03  -O1  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_16.f03  -O2  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_16.f03  -O2  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_16.f03  -O3 -fomit-frame-pointer  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_16.f03  -O3 -fomit-frame-pointer  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_16.f03  -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_16.f03  -O3 -fomit-frame-pointer -funroll-loops  compilation failed to produce execut\
able
FAIL: gfortran.dg/bind_c_usage_16.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for excess\
 errors)
WARNING: gfortran.dg/bind_c_usage_16.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  compilation f\
ailed to produce executable
FAIL: gfortran.dg/bind_c_usage_16.f03  -O3 -g  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_16.f03  -O3 -g  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_16.f03  -Os  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_16.f03  -Os  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_24.f90  -O0  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_24.f90  -O0  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_24.f90  -O1  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_24.f90  -O1  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_24.f90  -O2  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_24.f90  -O2  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_24.f90  -O3 -fomit-frame-pointer  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_24.f90  -O3 -fomit-frame-pointer  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_24.f90  -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_24.f90  -O3 -fomit-frame-pointer -funroll-loops  compilation failed to produce execut\
able
FAIL: gfortran.dg/bind_c_usage_24.f90  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for excess\
 errors)
WARNING: gfortran.dg/bind_c_usage_24.f90  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  compilation f\
ailed to produce executable
FAIL: gfortran.dg/bind_c_usage_24.f90  -O3 -g  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_24.f90  -O3 -g  compilation failed to produce executable
FAIL: gfortran.dg/bind_c_usage_24.f90  -Os  (test for excess errors)
WARNING: gfortran.dg/bind_c_usage_24.f90  -Os  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_3.f03  -O0  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_3.f03  -O0  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_3.f03  -O1  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_3.f03  -O1  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_3.f03  -O2  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_3.f03  -O2  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_3.f03  -O3 -fomit-frame-pointer  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_3.f03  -O3 -fomit-frame-pointer  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_3.f03  -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_3.f03  -O3 -fomit-frame-pointer -funroll-loops  compilation failed to produce execu\
table
FAIL: gfortran.dg/c_funloc_tests_3.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for exces\
s errors)
WARNING: gfortran.dg/c_funloc_tests_3.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  compilation \
failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_3.f03  -O3 -g  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_3.f03  -O3 -g  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_3.f03  -Os  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_3.f03  -Os  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_4.f03  -O0  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_4.f03  -O0  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_4.f03  -O1  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_4.f03  -O1  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_4.f03  -O2  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_4.f03  -O2  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_4.f03  -O3 -fomit-frame-pointer  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_4.f03  -O3 -fomit-frame-pointer  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_4.f03  -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_4.f03  -O3 -fomit-frame-pointer -funroll-loops  compilation failed to produce execu\
table
FAIL: gfortran.dg/c_funloc_tests_4.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for exces\
s errors)
WARNING: gfortran.dg/c_funloc_tests_4.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  compilation \
failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_4.f03  -O3 -g  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_4.f03  -O3 -g  compilation failed to produce executable
FAIL: gfortran.dg/c_funloc_tests_4.f03  -Os  (test for excess errors)
WARNING: gfortran.dg/c_funloc_tests_4.f03  -Os  compilation failed to produce executable
FAIL: gfortran.dg/c_ptr_tests_8.f03  -O0  (test for excess errors)
WARNING: gfortran.dg/c_ptr_tests_8.f03  -O0  compilation failed to produce executable
FAIL: gfortran.dg/c_ptr_tests_8.f03  -O1  (test for excess errors)
WARNING: gfortran.dg/c_ptr_tests_8.f03  -O1  compilation failed to produce executable
FAIL: gfortran.dg/c_ptr_tests_8.f03  -O2  (test for excess errors)
WARNING: gfortran.dg/c_ptr_tests_8.f03  -O2  compilation failed to produce executable
FAIL: gfortran.dg/c_ptr_tests_8.f03  -O3 -fomit-frame-pointer  (test for excess errors)
WARNING: gfortran.dg/c_ptr_tests_8.f03  -O3 -fomit-frame-pointer  compilation failed to produce executable
FAIL: gfortran.dg/c_ptr_tests_8.f03  -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
WARNING: gfortran.dg/c_ptr_tests_8.f03  -O3 -fomit-frame-pointer -funroll-loops  compilation failed to produce executab\
le
FAIL: gfortran.dg/c_ptr_tests_8.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for excess e\
rrors)
WARNING: gfortran.dg/c_ptr_tests_8.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  compilation fai\
led to produce executable
FAIL: gfortran.dg/c_ptr_tests_8.f03  -O3 -g  (test for excess errors)
WARNING: gfortran.dg/c_ptr_tests_8.f03  -O3 -g  compilation failed to produce executable
FAIL: gfortran.dg/c_ptr_tests_8.f03  -Os  (test for excess errors)
WARNING: gfortran.dg/c_ptr_tests_8.f03  -Os  compilation failed to produce executable
FAIL: gfortran.dg/c_size_t_test.f03  -O0  (test for excess errors)
WARNING: gfortran.dg/c_size_t_test.f03  -O0  compilation failed to produce executable
FAIL: gfortran.dg/c_size_t_test.f03  -O1  (test for excess errors)
WARNING: gfortran.dg/c_size_t_test.f03  -O1  compilation failed to produce executable
FAIL: gfortran.dg/c_size_t_test.f03  -O2  (test for excess errors)
WARNING: gfortran.dg/c_size_t_test.f03  -O2  compilation failed to produce executable
FAIL: gfortran.dg/c_size_t_test.f03  -O3 -fomit-frame-pointer  (test for excess errors)
WARNING: gfortran.dg/c_size_t_test.f03  -O3 -fomit-frame-pointer  compilation failed to produce executable
FAIL: gfortran.dg/c_size_t_test.f03  -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
WARNING: gfortran.dg/c_size_t_test.f03  -O3 -fomit-frame-pointer -funroll-loops  compilation failed to produce executab\
le
FAIL: gfortran.dg/c_size_t_test.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for excess e\
rrors)
WARNING: gfortran.dg/c_size_t_test.f03  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  compilation fai\
led to produce executable
FAIL: gfortran.dg/c_size_t_test.f03  -O3 -g  (test for excess errors)
WARNING: gfortran.dg/c_size_t_test.f03  -O3 -g  compilation failed to produce executable
FAIL: gfortran.dg/c_size_t_test.f03  -Os  (test for excess errors)
WARNING: gfortran.dg/c_size_t_test.f03  -Os  compilation failed to produce executable

The messages in the logfiles are similar:
Executing on host: /tmp/bad0516b/gccobj/gcc/xgcc -B/tmp/bad0516b/gccobj/gcc/ /tmp/bad0516b/gcc/gcc/testsuite/gcc.dg/cpp/19990407-1.c  -fno-diagnostics-show-caret    -ansi -pedantic-errors   -isystem /tmp/bad0516b/gccobj/cris-elf/./newlib/targ-include -isystem /tmp/bad0516b/gcc/newlib/libc/include -B/tmp/bad0516b/gccobj/cris-elf/./libgloss/cris/ -L/tmp/bad0516b/gccobj/cris-elf/./libgloss/cris -L/tmp/bad0516b/gcc/libgloss/cris  -B/tmp/bad0516b/gccobj/cris-elf/./newlib/ -L/tmp/bad0516b/gccobj/cris-elf/./newlib -sim3  -lm   -o ./19990407-1.exe    (timeout = 300)
/tmp/bad0516b/gcc/newlib/libc/include/machine/_default_types.h:98:39: error: use of C99 long long integer constant [-Wlong-long]^M
compiler exited with status 1
output is:
/tmp/bad0516b/gcc/newlib/libc/include/machine/_default_types.h:98:39: error: use of C99 long long integer constant [-Wlong-long]^M

FAIL: gcc.dg/cpp/19990407-1.c (test for excess errors)
Excess errors:
/tmp/bad0516b/gcc/newlib/libc/include/machine/_default_types.h:98:39: error: use of C99 long long integer constant [-Wlong-long]

WARNING: gcc.dg/cpp/19990407-1.c compilation failed to produce executable

I'm attaching 19990407-1.i and _default_types.h.  From what I can see, the latter is considered a system header by the preprocessor just as before, still a warning is now emitted that wasn't before.  A -Wno-system-headers has no effect.

According to -v, the preprocessor is invoked as "/tmp/bad0516b/gccobj/gcc/cc1 -E -quiet -v -iprefix /tmp/bad0516b/gccobj/gcc/../lib/gcc/cris-elf/4.8.0/ -isystem /tmp/bad0516b/gccobj/gcc/include -isystem /tmp/bad0516b/gccobj/gcc/include-fixed -isystem /tmp/bad0516b/gccobj/cris-elf/./newlib/targ-include -isystem /tmp/bad0516b/gcc/newlib/libc/include /tmp/bad0516b/gcc/gcc/testsuite/gcc.dg/cpp/19990407-1.c -melf -ansi -pedantic-errors -fno-diagnostics-show-caret -fpch-preprocess -o 19990407-1.i" which yields:

ignoring nonexistent directory "/tmp/bad0516b/gccobj/gcc/../lib/gcc/cris-elf/4.8.0/include"
ignoring nonexistent directory "/tmp/bad0516b/gccobj/gcc/../lib/gcc/cris-elf/4.8.0/include-fixed"
ignoring nonexistent directory "/tmp/bad0516b/gccobj/gcc/../lib/gcc/cris-elf/4.8.0/../../../../cris-elf/sys-include"
ignoring nonexistent directory "/tmp/bad0516b/gccobj/gcc/../lib/gcc/cris-elf/4.8.0/../../../../cris-elf/include"
ignoring nonexistent directory "/tmp/bad0516b/gccobj/gcc/../lib/gcc/../../lib/gcc/cris-elf/4.8.0/include"
ignoring nonexistent directory "/tmp/bad0516b/gccobj/gcc/../lib/gcc/../../lib/gcc/cris-elf/4.8.0/include-fixed"
ignoring nonexistent directory "/tmp/bad0516b/gccobj/gcc/../lib/gcc/../../lib/gcc/cris-elf/4.8.0/../../../../cris-elf/sys-include"
ignoring nonexistent directory "/tmp/bad0516b/gccobj/gcc/../lib/gcc/../../lib/gcc/cris-elf/4.8.0/../../../../cris-elf/include"
#include "..." search starts here:
#include <...> search starts here:
 /tmp/bad0516b/gccobj/gcc/include
 /tmp/bad0516b/gccobj/gcc/include-fixed
 /tmp/bad0516b/gccobj/cris-elf/./newlib/targ-include
 /tmp/bad0516b/gcc/newlib/libc/include
End of search list.
/tmp/bad0516b/gcc/newlib/libc/include/machine/_default_types.h:98:39: error: use of C99 long long integer constant [-Wlong-long]

Author of the patch in that revision is CC:ed.
Comment 1 Hans-Peter Nilsson 2012-05-23 20:21:01 UTC
Created attachment 27484 [details]
The offending system header _default_types.h, fresh from newlib.

A brief look in gcc-testresults archives expectedly shows this regression for other newlib targets too.
Comment 2 Greta Yorsh 2012-05-24 13:08:57 UTC
The following tests fail on arm-none-eabi:

FAIL: gcc.dg/cpp/19990407-1.c (test for excess errors)
FAIL: gcc.dg/cpp/paste12.c (test for excess errors)
FAIL: gcc.dg/cpp/strp1.c (test for excess errors)
FAIL: gcc.dg/cpp/strp2.c (test for excess errors)
FAIL: gcc.dg/struct-ret-libc.c (test for excess errors)

For example:

/work/builds/a9-may/install/bin/arm-none-eabi-gcc /work/local-checkouts/gcc-fsf/gcc/testsuite/gcc.dg/cpp/19990407-1.c -mcpu=cortex-a9 -mfloat-abi=softfp -mfpu=neon -fno-diagnostics-show-caret -pedantic-errors -o 19990407-1.exe
/work/builds/a9-may/install/arm-none-eabi/include/machine/_default_types.h:98:39: error: use of C99 long long integer constant [-Wlong-long]
Comment 3 Dodji Seketeli 2012-05-25 09:58:42 UTC
It seems to me that this issue is dealt with by the patch I have proposed at http://gcc.gnu.org/ml/gcc-patches/2012-05/msg01389.html.  The discussion on that patch is still going on.

Could you please try that patch and reply to the discussion there to say if it address the issue on your target?

Thanks.
Comment 4 Hans-Peter Nilsson 2012-05-26 01:50:09 UTC
(In reply to comment #3)
> Could you please try that patch and reply to the discussion there to say if it
> address the issue on your target?

It does thanks, see the reply.
Comment 5 Greta Yorsh 2012-05-28 15:28:16 UTC
(In reply to comment #3)
> It seems to me that this issue is dealt with by the patch I have proposed at
> http://gcc.gnu.org/ml/gcc-patches/2012-05/msg01389.html.  The discussion on
> that patch is still going on.
> 
> Could you please try that patch and reply to the discussion there to say if it
> address the issue on your target?
> 
> Thanks.

This patch fixes the regressions observed for arm-none-eabi.
Comment 6 Dodji Seketeli 2012-06-04 19:20:16 UTC
Author: dodji
Date: Mon Jun  4 19:19:58 2012
New Revision: 188203

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=188203
Log:
PR preprocessor/53463 - Fix system header detection for built-in macro tokens

The location for a built-in macro token is BUILTIN_LOCATION.  When we
see that location value, we cannot know if that token was used in a
system header or not.  And that can trigger some unwanted warnings on
e.g, the use of __LONG_LONG_MAX__ built-in macro in system headers
when we compile with -pedantic, like in the test case accompanying
this patch.

In that case, I think we ought to step-up to see where the built-in
macro has been expanded, until we see a location that is not for a
built-in macro.  Then we can check if the resulting location is in a
system header or not.

Now that we step up to the location of first non-built-in-macro token,
it appeared that for
testsuite/c-c++-common/dfp/convert-int-saturate.c, G++ then fails to
emit the warning in:

    volatile unsigned int usi;
    int
    main ()
    {
      usi = DEC32_MAX;  /* { dg-warning "overflow in implicit constant conversion" } */
     ...
    }

Because DEC32_MAX is defined in the system header float.h as a
built-in macro:

    #define DEC32_MAX	__DEC32_MAX__

And during the parsing of the assignment expression that should have
led to the warning above, input_location is set to the location for
the DEC32_MAX, which is actually the location for the built-in
__DECL32_MAX_EXP.

A possible fix is to use the location of the "=" operator as the
default location for assignment expressions.  This is what the patch
does.

I had to adjust a couple of tests to arrange for this.

Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.

libcpp/

	PR preprocessor/53463
	* line-map.c (linemap_location_in_system_header_p): For built-in
	macro tokens, check the first expansion point location for that is
	not for a token coming from a built-in macro.

gcc/cp/

	PR preprocessor/53463
	* parser.c (cp_parser_assignment_expression): Use the location
	for the LHS as the default location for the expression.

gcc/testsuite/

	PR preprocessor/53463
	* g++.dg/cpp/limits.C: New test.
	* g++.dg/parse/error19.C: Adjust.
	* g++.dg/warn/Wconversion-real-integer2.C: Likewise.
	* g++.dg/warn/pr35635.C: Likewise.
	* g++.old-deja/g++.pt/assign1.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/cpp/limits.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/parse/error19.C
    trunk/gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C
    trunk/gcc/testsuite/g++.dg/warn/pr35635.C
    trunk/gcc/testsuite/g++.old-deja/g++.pt/assign1.C
    trunk/libcpp/ChangeLog
    trunk/libcpp/line-map.c
Comment 7 dodji@seketeli.org 2012-06-04 19:57:31 UTC
Hans-Peter and Greta,

Could you please test trunk and, if the commit above fixes the issue for
you, close the bug please?

Thank you in advance.
Comment 8 Hans-Peter Nilsson 2012-06-05 08:29:39 UTC
(In reply to comment #7)
> Hans-Peter and Greta,
> 
> Could you please test trunk and, if the commit above fixes the issue for
> you, close the bug please?

Yes, thanks. The witch is cooked (SCNR :)