]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/tree-diagnostic.h
Emit macro expansion related diagnostics
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Oct 2011 09:59:27 +0000 (09:59 +0000)
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Oct 2011 09:59:27 +0000 (09:59 +0000)
commit3de02a0fadcb82dc5ec168ca091a6f47ffe0575b
treef61c52285dfb7b5d1466077cc0069c8ecc04e810
parentce70f43356e19c14deb3a89da25ebe89d6cb255a
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
16 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/cp/ChangeLog
gcc/cp/error.c
gcc/diagnostic.c
gcc/diagnostic.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/cpp/macro-exp-tracking-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/macro-exp-tracking-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/macro-exp-tracking-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/macro-exp-tracking-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/cpp/pragma-diagnostic-2.c [new file with mode: 0644]
gcc/testsuite/lib/prune.exp
gcc/toplev.c
gcc/tree-diagnostic.c
gcc/tree-diagnostic.h