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

            Bug ID: 66208
           Summary: macro location not detected
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: manu at gcc dot gnu.org
  Target Milestone: ---

From: https://gcc.gnu.org/ml/gcc-help/2015-05/msg00082.html

void foox (char*, ...) __attribute__ ((nonnull (1)));
#define foo(p) foox (p, "p is null")
#define bar(p) _Static_assert (p, "p is null")

void baz (void) {
  foox (0, "p is null");
  foo (0);
  bar (0);
}

This should print:

test.c:2:16: warning: null argument where non-null required (argument 1)
[-Wnonnull]
 #define foo(p) foox (p, "p is null")
                ^
test.c:7:3: note: in expansion of macro ‘foo’
   foo (0);
   ^

but for some reason, the input_location at the time of warning is not a virtual
location coming from a macro map. It seems that input_location is not adjusted
correctly before giving this warning 

test.c:6:3: warning: null argument where non-null required (argument 1)
[-Wnonnull]
   (foox (0, "p is null"));
   ^
test.c:7:3: warning: null argument where non-null required (argument 1)
[-Wnonnull]
   (foo (0));
   ^

and it always points to the first location given in the line, which was never
updated to be a macro location.

Reply via email to