Add "included from" and macro expansion information in error messages
Ideally Verilator would report messages similar to gcc in these scenarios. Something like this:
$ gcc foo.c In file included from bar.h:3:0, from foo.c:1: foo.c: In function ‘main’: baz.h:3:13: error: ‘abc’ undeclared (first use in this function) #define QUX abc ^ bar.h:5:14: note: in expansion of macro ‘QUX’ #define QUUZ QUX ^~~ foo.c:4:12: note: in expansion of macro ‘QUUZ’ return QUUZ; ^~~~
This probably relates to issue #1435. Also, I suspect this will work best as two patches: "included from" and macro expansion.
#4 Updated by Wilson Snyder 30 days ago
Includes easier than thought as preproc already records the include tree. Also added easy insertion point for adding source annotation later. Pushed to git towards 4.017.
Punting on defines for now as this will be hard to communicate within the preproc and beyond, think better to get column information first (bug1435), then may revisit.
#5 Updated by Wilson Snyder 12 days ago
Notes on how GCC tracks defines.
Debug can be seen with "g++ -fdebug-cpp -E -c file.cpp". line-map.c's linemap_dump_location describes the format:
/* P: path, L: line, C: column, S: in-system-header, M: map address, E: macro expansion?, LOC: original location, R: resolved location */
Passing info from CPP to backend is enabled with "-ftrack-macro-expansion"
#6 Updated by Wilson Snyder 8 days ago
- Status changed from Feature to Closed
Macro expansion is very difficult as requires tracking recursive information on every token through the preprocessor.
Closing out as included's froms there, and unlikely to get more in the medium-long term unless someone has a lot of time.
Also available in: Atom