diff options
author | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-17 09:59:27 +0000 |
---|---|---|
committer | dodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-10-17 09:59:27 +0000 |
commit | 3de02a0fadcb82dc5ec168ca091a6f47ffe0575b (patch) | |
tree | f61c52285dfb7b5d1466077cc0069c8ecc04e810 /gcc/toplev.c | |
parent | ce70f43356e19c14deb3a89da25ebe89d6cb255a (diff) | |
download | gcc-3de02a0fadcb82dc5ec168ca091a6f47ffe0575b.tar.gz |
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
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180083 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/toplev.c b/gcc/toplev.c index 63e229ef7a8..c43869c3b31 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1171,6 +1171,9 @@ general_init (const char *argv0) can give warnings and errors. */ diagnostic_initialize (global_dc, N_OPTS); diagnostic_starter (global_dc) = default_tree_diagnostic_starter; + /* By default print macro expansion contexts in the diagnostic + finalizer -- for tokens resulting from macro macro expansion. */ + diagnostic_finalizer (global_dc) = virt_loc_aware_diagnostic_finalizer; /* Set a default printer. Language specific initializations will override it later. */ pp_format_decoder (global_dc->printer) = &default_tree_printer; |