Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "included from" and macro expansion information in error messages #1439

Closed
veripoolbot opened this issue May 14, 2019 · 5 comments
Closed
Assignees
Labels
area: lint Issue involves SystemVerilog lint checking resolution: fixed Closed; fixed

Comments

@veripoolbot
Copy link
Contributor


Author Name: Todd Strader (@toddstrader)
Original Redmine Issue: 1439 from https://www.veripool.org

Original Assignee: Todd Strader (@toddstrader)


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.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-06-22T16:52:04Z


Have you looked at this?, if not will look at the include part first which seems easier.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Todd Strader (@toddstrader)
Original Date: 2019-06-22T17:01:23Z


I haven't done anything yet. Please feel free.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-06-22T21:01:44Z


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 (#�), then may revisit.

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-07-11T00:31:26Z


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"

@veripoolbot
Copy link
Contributor Author


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2019-07-15T01:44:57Z


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: lint Issue involves SystemVerilog lint checking resolution: fixed Closed; fixed
Projects
None yet
Development

No branches or pull requests

2 participants