[llvm-bugs] [Bug 35154] New: Clang's diagnostic suppression pragma fails in a particular macro expansion case

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 31 16:52:16 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=35154

            Bug ID: 35154
           Summary: Clang's diagnostic suppression pragma fails in a
                    particular macro expansion case
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: arphaman at gmail.com
                CC: llvm-bugs at lists.llvm.org

Clang fails to silence the -Wunused-value warning in the following test-case:

```
@class Test;

#define nil2 0

#define SOMETHING(macro) macro

#define Expected(invocation) \
({ \
    SilenceWarning( \
        Test *recorder = nil2; \
        recorder; \
    ); \
})

#define SilenceWarning(macro) \
({ \
    _Pragma("clang diagnostic push") \
    _Pragma("clang diagnostic ignored \"-Wunused-value\"") \
    macro \
    _Pragma("clang diagnostic pop") \
})

int test1() {
  return 5;
}

void foo(Test *other) {
  SOMETHING(
   Expected(test1());
  )
}
```

Interestingly enough, if the use of `nil2` is replaced by `0` then the warning
is suppressed correctly.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171031/bfba2a84/attachment-0001.html>


More information about the llvm-bugs mailing list