http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24985
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dodji at gcc dot gnu.org
--- Comment #26 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-04-07
12:53:34 UTC ---
A sneak-peek into the future ;-)
manuel@gcc12:~/test2/186200M/build/gcc$ ./cc1 -ftrack-macro-expansion
~/macro-clang.c
foo
/home/manuel/macro-clang.c: In function ‘foo’:
/home/manuel/macro-clang.c:2:94: error: invalid operands to binary < (have
‘struct mystruct’ and ‘float’)
#define MYMAX(A,B) __extension__ ({ __typeof__(A) __a = (A); __typeof__(B)
__b = (B); __a < __b ? __b : __a; })
^
/home/manuel/macro-clang.c:2:94: note: in expansion of macro 'MYMAX'
#define MYMAX(A,B) __extension__ ({ __typeof__(A) __a = (A); __typeof__(B)
__b = (B); __a < __b ? __b : __a; })
^
/home/manuel/macro-clang.c:8:11: note: expanded from here
float x = MYMAX(p, f);
^
This is not possible with the patch just posted, but I will send this follow up
after the initial part is committed. Of course, it needs some fine-tuning to
avoid repetitions, but this is a problem with the locations given by the macro
expansion unwinder, which, in my opinion, doesn't give the best location for
each message and already produces repetitions. See:
/home/manuel/macro-caret.c: In function ‘g’:
/home/manuel/macro-caret.c:5:14: error: invalid operands to binary << (have
‘double’ and ‘int’)
OPERATE (A,<<,B)
^
/home/manuel/macro-caret.c:2:9: note: in expansion of macro 'OPERATE'
OPRD1 OPRT OPRD2;
^
/home/manuel/macro-caret.c:5:3: note: expanded from here
OPERATE (A,<<,B)
^
/home/manuel/macro-caret.c:5:14: note: in expansion of macro 'SHIFTL'
OPERATE (A,<<,B)
^
/home/manuel/macro-caret.c:8:3: note: expanded from here
SHIFTL (A,1)
^
/home/manuel/macro-caret.c:8:3: note: in expansion of macro 'MULT'
SHIFTL (A,1)
^
/home/manuel/macro-caret.c:13:3: note: expanded from here
MULT (1.0);// 1.0 << 1; <-- so this is an error.
^
Another possibility could be to print the preprocessed string when saying "in
expansion". However, I am not sure how hard it will be to obtain the
preprocessed string (or to re-create it at runtime). Help and pointers on how
to achieve that are welcome.
Dodji, are you planning to propose to enable -ftrack-macro-expansion by default
in GCC 4.8?