[LLVMbugs] [Bug 10214] New: Macro expansion stack fails to list bottom most macro for errors in arguments

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 27 23:59:38 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=10214

           Summary: Macro expansion stack fails to list bottom most macro
                    for errors in arguments
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: chandlerc at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=6795)
 --> (http://llvm.org/bugs/attachment.cgi?id=6795)
Patch originally proposed for PR9279

This is reduced from one of several test cases I provided as part of my patch
to PR9279. It is also one of the problems listed on the original PR.

Given:
% cat x1.c
#define A 1
#define B A
#define C B
void bar() {
  C;
}

#define M1(x) x
#define M2(x) M1(x)
#define M3(x) M2(x)

void test() {
  M3(1);
}

Clang currently prints (after Chris's patch for PR9279):
% ./bin/clang -fsyntax-only x1.c
x1.c:5:3: warning: expression result unused [-Wunused-value]
  C;
  ^
x1.c:3:11: note: instantiated from:
#define C B
          ^
x1.c:2:11: note: instantiated from:
#define B A
          ^
x1.c:1:11: note: instantiated from:
#define A 1
          ^
x1.c:13:3: warning: expression result unused [-Wunused-value]
  M3(1);
  ^~~~~
x1.c:10:15: note: instantiated from:
#define M3(x) M2(x)
              ^
x1.c:9:15: note: instantiated from:
#define M2(x) M1(x)
              ^
x1.c:13:3: note: instantiated from:
  M3(1);
     ^
2 warnings generated.

Note that M1's definition isn't shown, but A's definition is.

With my patch for PR9279 we get what I would expect here:
% ./bin/clang -fsyntax-only x1.c 
x1.c:5:3: warning: expression result unused [-Wunused-value]
  C;
  ^
x1.c:3:11: note: instantiated from:
#define C B
          ^
x1.c:2:11: note: instantiated from:
#define B A
          ^
x1.c:1:11: note: instantiated from:
#define A 1
          ^
x1.c:13:6: warning: expression result unused [-Wunused-value]
  M3(1);
  ~~~^~
x1.c:10:18: note: instantiated from:
#define M3(x) M2(x)
                 ^
x1.c:9:18: note: instantiated from:
#define M2(x) M1(x)
                 ^
x1.c:8:15: note: instantiated from:
#define M1(x) x
              ^
2 warnings generated.


I've attached (an updated version of) my patch for PR9279 so that people can
replicate these. This patch may be overkill for this particular bug, but it
fixes several interrelated issues at the same time. See the original PR for a
discussion of the performance and memory impact.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list