LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 35154 - Clang's diagnostic suppression pragma fails in a particular macro expansion case
Summary: Clang's diagnostic suppression pragma fails in a particular macro expansion case
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-10-31 16:52 PDT by Alex Lorenz
Modified: 2019-04-10 18:47 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Lorenz 2017-10-31 16:52:16 PDT
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.
Comment 1 Richard Smith 2019-04-10 18:47:54 PDT
This appears to have been fixed since Clang 3.2.