Go to file
Dodji Seketeli 7ca643e17e 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.

From-SVN: r188203
2012-06-04 21:19:58 +02:00
boehm-gc Regenerate configure files for libtool.m4 change 2012-05-16 15:11:18 -07:00
config mt-sde: Fix typos. 2012-05-29 16:54:57 +01:00
contrib Add new skeleton ChangeLog file generator to contrib/ 2012-05-31 14:01:15 -04:00
fixincludes configure.ac: Use GCC_AC_FUNC_MMAP_BLACKLIST instead of gcc_AC_FUNC_MMAP_BLACKLIST. 2012-05-29 21:28:57 +02:00
gcc PR preprocessor/53463 - Fix system header detection for built-in macro tokens 2012-06-04 21:19:58 +02:00
gnattools Remove obsolete IRIX 6.5 support 2012-03-14 16:33:37 +00:00
include leb128.h: #include stdint.h, inttypes.h. 2012-05-23 23:42:25 +00:00
INSTALL
intl
libada Adjust. 2012-05-06 09:24:21 +00:00
libatomic re PR other/53231 (libatomic/tas_n.c💯10: error: 'ret' undeclared (first use in this function)) 2012-05-22 23:54:32 +00:00
libcpp PR preprocessor/53463 - Fix system header detection for built-in macro tokens 2012-06-04 21:19:58 +02:00
libdecnumber warnings.m4 (ACX_PROG_CC_WARNING_OPTS): Avoid leading dash in expr call. 2011-12-20 16:54:12 +00:00
libffi Regenerate configure files for libtool.m4 change 2012-05-16 15:11:18 -07:00
libgcc Fix bug added to sparc 64-bit sub_ddmmss() implementation. 2012-06-03 18:54:59 -07:00
libgfortran PR 53456 Fix incorrect ChangeLog entry. 2012-06-04 22:15:21 +03:00
libgo runtime: Better SWIG interface for allocating Go memory from C/C++. 2012-06-04 05:34:59 +00:00
libgomp Regenerate configure files for libtool.m4 change 2012-05-16 15:11:18 -07:00
libiberty demangle-expected: Add regression test. 2012-05-22 13:55:02 +00:00
libitm eh_cpp.cc: Fix __cxa_end_catch declaration. 2012-05-21 22:48:00 +00:00
libjava re PR bootstrap/52700 (lib* configure fails on --enable-symvers=gnu-versioned-namespace.) 2012-05-21 17:34:25 +00:00
libmudflap * mf-impl.h: Fix typo. 2012-05-29 20:21:05 +01:00
libobjc Regenerate configure files for libtool.m4 change 2012-05-16 15:11:18 -07:00
libquadmath re PR target/51007 (Quadmath I/O doesn't work on MinGW) 2012-05-31 18:51:27 +00:00
libssp re PR target/51007 (Quadmath I/O doesn't work on MinGW) 2012-05-31 18:51:27 +00:00
libstdc++-v3 * doc/xml/manual/status_cxx2011.xml: Correct C++11 status table. 2012-06-01 01:47:32 +01:00
lto-plugin * lto-plugin.c: Fix typo. 2012-05-29 20:21:25 +01:00
maintainer-scripts crontab: Enable snapshots from gcc-4_7-branch. 2012-03-22 09:25:49 +00:00
zlib Regenerate configure files for libtool.m4 change 2012-05-16 15:11:18 -07:00
ABOUT-NLS
ChangeLog MAINTAINERS (Write After Approval): Add myself. 2012-05-29 20:18:29 +00:00
ChangeLog.tree-ssa
compile
config-ml.in
config.guess
config.rpath
config.sub Update config.sub to 2012-04-18 version from official repo. 2012-04-25 15:48:28 +00:00
configure re PR bootstrap/50461 (mpfr.h found in mpfr-3.1.0/src instead of mpfr-3.0.1/. as previously) 2012-05-09 16:20:17 +00:00
configure.ac re PR bootstrap/50461 (mpfr.h found in mpfr-3.1.0/src instead of mpfr-3.0.1/. as previously) 2012-05-09 16:20:17 +00:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4 Add x32 support to libtool.m4 2012-05-15 09:07:28 -07:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS MAINTAINERS (Write After Approval): Add myself. 2012-05-29 20:18:29 +00:00
Makefile.def Add libatomic as a target library. 2012-05-01 08:48:28 -07:00
Makefile.in Makefile.tpl (gcc-no-fixedincludes): Rename into ... 2012-05-16 13:37:14 +00:00
Makefile.tpl Makefile.tpl (gcc-no-fixedincludes): Rename into ... 2012-05-16 13:37:14 +00:00
missing
mkdep
mkinstalldirs
move-if-change
README
symlink-tree
ylwrap

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.