Go to file
Dodji Seketeli c4ca1a0961 Strip "<built-in>" loc from displayed expansion context
Now that diagnostics for tokens coming from macro expansions point to
the spelling location of the relevant token (and then displays the
context of the expansion), some ugly (not so seldom) corner cases can
happen.

When the relevant token is a built-in token (which means the location
of that token is BUILTINS_LOCATION) the location prefix displayed to
the user in the diagnostic line is the "<built-in>:0:0" string.  For
instance:

    <built-in>:0:0: warning: conversion to 'float' alters 'int' constant value

For the user, I think this is surprising and useless.

A more user-friendly approach would be to refer to the first location
that (in the reported macro expansion context) is for a location in
real source code, like what is shown in the new test case
gcc/testsuite/g++.dg/warn/Wconversion-real-integer2.C accompanying
this patch.

To do this, I am making the line-map module provide a new
linemap_unwind_to_first_non_reserved_loc function that resolves a
virtual location to the first spelling location that is in real source
code.

I am then using that facility in the diagnostics printing module and
in the macro unwinder to avoid printing diagnostics lines that refer
to the locations for built-ins or more generally for reserved
locations.  Note that when I start the dance of skipping a built-in
location I also skip locations that are in system headers, because it
turned out that a lot of those built-ins are actually used in system
headers (e.g, "#define INT_MAX __INT_MAX__" where __INT_MAX__ is a
built-in).

Besides the user-friendliness gain, this patch allows a number of
regression tests to PASS unchanged with and without
-ftrack-macro-expansion.

Tested and bootstrapped on x86_64-unknown-linux-gnu against trunk.

Note that the bootstrap with -ftrack-macro-expansion exhibits other
separate issues that are addressed in subsequent patches.  This patch
just fixes one class of problems.

The patch does pass bootstrap with -ftrack-macro-expansion turned off,
though.

libcpp/

	* include/line-map.h (linemap_unwind_toward_expansion): Fix typo
	in comment.
	(linemap_unwind_to_first_non_reserved_loc): Declare new function.
	* line-map.c (linemap_unwind_to_first_non_reserved_loc): Define
	new function.

gcc/

	* input.c (expand_location_1): When expanding to spelling location
	in a context of a macro expansion, skip reserved system header
	locations.  Update comments.  * tree-diagnostic.c
	(maybe_unwind_expanded_macro_loc): Likewise.

gcc/testsuite/

	* g++.dg/warn/Wconversion-real-integer2.C: New test.
	* g++.dg/warn/Wconversion-real-integer-3.C: Likewise.
	* g++.dg/warn/conversion-real-integer-3.h: New header used by the
	new test above.

From-SVN: r186970
2012-04-30 13:42:12 +02:00
boehm-gc Fix changelog format. 2012-02-28 18:02:56 +00:00
config mmap.m4: Use *vms* instead of vms*. 2012-04-03 12:07:28 +00:00
contrib compare_tests: Append '/' to make 'find' traverse symlinked directories. 2012-04-24 07:22:41 +00:00
fixincludes fixincl.c (fix_with_system): Add missing specifier. 2012-04-24 09:24:55 +00:00
gcc Strip "<built-in>" loc from displayed expansion context 2012-04-30 13:42:12 +02:00
gnattools Remove obsolete IRIX 6.5 support 2012-03-14 16:33:37 +00:00
include * dwarf2.def (DW_OP): Add DW_OP_GNU_addr_index. 2012-04-28 21:37:19 +00:00
INSTALL
intl
libada Makefile.in (bindir): Import from autoconf and pass down to submake. 2012-02-24 16:17:01 +00:00
libcpp Strip "<built-in>" loc from displayed expansion context 2012-04-30 13:42:12 +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 ffi.c (ffi_prep_args_SYSV): Declare double_tmp. 2012-04-02 13:29:22 -05:00
libgcc config.host (mips64*-*-linux*, [...]): Remove. 2012-04-28 08:03:54 +00:00
libgfortran re PR libfortran/53051 (I/O: Support reading floating-point numbers which use "Q" for the exponent) 2012-04-22 19:28:34 +02:00
libgo re PR go/52358 (math FAILs on Solaris 8 and 9) 2012-04-27 16:38:11 +00:00
libgomp prune.exp (TEST_ALWAYS_FLAGS): If undefined, set to empty. 2012-04-11 20:15:35 +00:00
libiberty dwarf2out.c (dwarf_stack_op_name): Use get_DW_OP_name. 2012-04-27 14:14:14 +00:00
libitm Use long long in gtm_jmpbuf for x86-64 2012-04-04 08:49:23 -07:00
libjava defineclass.cc (MAJOR_1_7, MINOR_1_7): New. 2012-04-23 13:33:32 +00:00
libmudflap re PR c++/24985 (caret diagnostics) 2012-04-11 09:26:48 +00:00
libobjc Remove obsolete Tru64 UNIX V5.1B support 2012-03-12 15:35:56 +00:00
libquadmath Additional fixes for FreeBSD-10 build: 2011-11-21 20:22:35 +01:00
libssp Additional fixes for FreeBSD-10 build: 2011-11-21 20:22:35 +01:00
libstdc++-v3 re PR libstdc++/51795 (linear_congruential_engine doesn't work correctly) 2012-04-29 23:36:09 +00:00
lto-plugin re PR lto/50616 (lto1.exe: internal compiler error: invalid resolution in the resolution file) 2012-02-22 11:19:22 +01:00
maintainer-scripts crontab: Enable snapshots from gcc-4_7-branch. 2012-03-22 09:25:49 +00:00
zlib 2012-03-02 Matthias Klose <doko@ubuntu.com> 2012-03-02 17:15:20 +00:00
ABOUT-NLS
ChangeLog Update config.sub to 2012-04-18 version from official repo. 2012-04-25 15:48:28 +00:00
ChangeLog.tree-ssa
compile
config-ml.in MAINTAINERS (crx port, [...]): Remove. 2011-03-22 19:58:18 +00:00
config.guess oops - omitted from previous delta. 2011-06-06 10:34:35 +00:00
config.rpath Remove freebsd1 from libtool.m4 macros and config.rpath. 2011-02-13 11:45:53 +00:00
config.sub Update config.sub to 2012-04-18 version from official repo. 2012-04-25 15:48:28 +00:00
configure Remove obsolete IRIX 6.5 support 2012-03-14 16:33:37 +00:00
configure.ac Remove obsolete IRIX 6.5 support 2012-03-14 16:33:37 +00:00
COPYING
COPYING3
COPYING3.LIB
COPYING.LIB
COPYING.RUNTIME
depcomp
install-sh
libtool-ldflags
libtool.m4 Additional fixes for FreeBSD-10 build: 2011-11-21 20:22:35 +01:00
lt~obsolete.m4
ltgcc.m4
ltmain.sh
ltoptions.m4
ltsugar.m4
ltversion.m4
MAINTAINERS Add myself in Write After Approval list in MAINTAINERS file. 2012-04-24 07:49:14 +00:00
Makefile.def re PR bootstrap/51686 ("make install-strip-gcc" didn't install liblto-plugin* files) 2012-01-02 10:59:04 +00:00
Makefile.in re PR bootstrap/51686 ("make install-strip-gcc" didn't install liblto-plugin* files) 2012-01-02 10:59:04 +00:00
Makefile.tpl configure.ac: Add tool checks for READELF and READELF_FOR_TARGET. 2011-11-09 13:57:26 -05: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.