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/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/diagnostic.h')
-rw-r--r-- | gcc/diagnostic.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 8074354..4b1265b 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -253,7 +253,7 @@ extern diagnostic_context *global_dc; /* Diagnostic related functions. */ extern void diagnostic_initialize (diagnostic_context *, int); extern void diagnostic_finish (diagnostic_context *); -extern void diagnostic_report_current_module (diagnostic_context *); +extern void diagnostic_report_current_module (diagnostic_context *, location_t); /* Force diagnostics controlled by OPTIDX to be kind KIND. */ extern diagnostic_t diagnostic_classify_diagnostic (diagnostic_context *, |