Project

General

Profile

[logo] 
 
Home
News
Activity
About/Contact
Major Tools
  Dinotrace
  Verilator
  Verilog-mode
  Verilog-Perl
Other Tools
  BugVise
  CovVise
  Force-Gate-Sim
  Gspice
  IPC::Locker
  Rsvn
  SVN::S4
  Voneline
  WFH
General Info
  Papers

Issue #1439

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

Added by Todd Strader 4 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Lint
% Done:

0%


Description

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.

History

#1 Updated by Wilson Snyder 4 months ago

  • Category set to Lint
  • Status changed from New to Feature

#2 Updated by Wilson Snyder 3 months ago

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

#3 Updated by Todd Strader 3 months ago

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

#4 Updated by Wilson Snyder 3 months 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 2 months 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 2 months 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