This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/62161] New: more precise locations for command-line diagnostics


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62161

            Bug ID: 62161
           Summary: more precise locations for command-line diagnostics
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manu at gcc dot gnu.org

manuel@gcc10:~$ cc1 -D A=2 redef.c
redef.c:1:0: warning: "A" redefined
 #define A 1
 ^
<command-line>:0:0: note: this is the location of the previous definition

We could print instead:

<command-line>:1:4: note: this is the location of the previous definition
-D A=2 redef.c
   ^

clang tries to do something similar but they print some kind of intermediate
file:

manuel@gcc10:~$ clang -D A=2 redef.c
redef.c:1:9: warning: 'A' macro redefined
#define A 1
        ^
<command line>:1:9: note: previous definition is here
#define A 2
        ^

One way is to have some location_t bit that tells us when something is the
command-line and show_locus can handle this bit to not look a file but use the
command-line string as the line.

Another way is that the location code that looks up the line handles this
transparently (when we create the line-map file for command-line, we push the
command-line string somewhere).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]