diff options
author | Tom Tromey <tromey@redhat.com> | 2011-10-17 09:59:27 +0000 |
---|---|---|
committer | Dodji Seketeli <dodji@gcc.gnu.org> | 2011-10-17 11:59:27 +0200 |
commit | 07a0b324eb7e353146340f00db380c6d92851fc9 (patch) | |
tree | f61c52285dfb7b5d1466077cc0069c8ecc04e810 /gcc/tree-diagnostic.h | |
parent | 92582b753e34fd574b6a5672b2f82979c966187a (diff) | |
download | gcc-07a0b324eb7e353146340f00db380c6d92851fc9.zip gcc-07a0b324eb7e353146340f00db380c6d92851fc9.tar.gz gcc-07a0b324eb7e353146340f00db380c6d92851fc9.tar.bz2 |
Emit macro expansion related diagnostics
In this third instalment the diagnostic machinery -- when faced with
the virtual location of a token resulting from macro expansion -- uses
the new linemap APIs to unwind the stack of macro expansions that led
to that token and emits a [hopefully] more useful message than what we
have today.
diagnostic_report_current_module has been slightly changed to use the
location given by client code instead of the global input_location
variable. This results in more precise diagnostic locations in
general but then the patch adjusts some C++ tests which output changed
as a result of this.
Three new regression tests have been added.
The mandatory screenshot goes like this:
[dodji@adjoa gcc]$ cat -n test.c
1 #define OPERATE(OPRD1, OPRT, OPRD2) \
2 OPRD1 OPRT OPRD2;
3
4 #define SHIFTL(A,B) \
5 OPERATE (A,<<,B)
6
7 #define MULT(A) \
8 SHIFTL (A,1)
9
10 void
11 g ()
12 {
13 MULT (1.0);/* 1.0 << 1; <-- so this is an error. */
14 }
[dodji@adjoa gcc]$ ./cc1 -quiet -ftrack-macro-expansion test.c
test.c: In function 'g':
test.c:5:14: erreur: invalid operands to binary << (have 'double' and 'int')
test.c:2:9: note: in expansion of macro 'OPERATE'
test.c:5:3: note: expanded from here
test.c:5:14: note: in expansion of macro 'SHIFTL'
test.c:8:3: note: expanded from here
test.c:8:3: note: in expansion of macro 'MULT2'
test.c:13:3: note: expanded from here
Co-Authored-By: Dodji Seketeli <dodji@redhat.com>
From-SVN: r180083
Diffstat (limited to 'gcc/tree-diagnostic.h')
-rw-r--r-- | gcc/tree-diagnostic.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/tree-diagnostic.h b/gcc/tree-diagnostic.h index 7d88089..6b8e8e6 100644 --- a/gcc/tree-diagnostic.h +++ b/gcc/tree-diagnostic.h @@ -52,5 +52,6 @@ along with GCC; see the file COPYING3. If not see void default_tree_diagnostic_starter (diagnostic_context *, diagnostic_info *); extern void diagnostic_report_current_function (diagnostic_context *, diagnostic_info *); - +void virt_loc_aware_diagnostic_finalizer (diagnostic_context *, + diagnostic_info *); #endif /* ! GCC_TREE_DIAGNOSTIC_H */ |