Issue 63897
Summary -Woverloaded-shift-op-parentheses bugs
Labels
Assignees
Reporter jeremy-rifkin
    **Background:** I am the author of a library called libassert. The library does some tricks to decompose a user-provided _expression_ into a left and right hand side with something along the lines of `expression_decomposer{} << expr`.

**Bug:**
This triggers `-Woverloaded-shift-op-parentheses`
```cpp
class test_class {
 void something_else() {
        std::string s = "test\n";
 ASSERT(s == "test");
    }
};
```
This does not:
```cpp
void something_else() {
    std::string s = "test\n";
    ASSERT(s == "test");
}
```


Additionally, `_Pragma("GCC diagnostic ignored \"-Woverloaded-shift-op-parentheses\"")` doesn't work to suppress the buggy error message. https://godbolt.org/z/ef9sn4fYb

The relevant part of the code in question looks something like

```cpp
 #if LIBASSERT_IS_GCC
  #define LIBASSERT_EXPRESSION_DECOMP_WARNING_PRAGMA \
     _Pragma("GCC diagnostic ignored \"-Wparentheses\"") \
 _Pragma("GCC diagnostic ignored \"-Wuseless-cast\"") // #49
 #else
  #define LIBASSERT_EXPRESSION_DECOMP_WARNING_PRAGMA \
 _Pragma("GCC diagnostic ignored \"-Wparentheses\"") \
 _Pragma("GCC diagnostic ignored \"-Woverloaded-shift-op-parentheses\"")
 #endif
...
#define ASSERT_INVOKE(expr, doreturn, check_expression, name, type, failaction, ...) \
        LIBASSERT_IGNORE_UNUSED_VALUE \
        LIBASSERT_STMTEXPR( \
          LIBASSERT_WARNING_PRAGMA_PUSH \
 LIBASSERT_EXPRESSION_DECOMP_WARNING_PRAGMA \
          auto libassert_decomposer = \
 libassert::detail::expression_decomposer(libassert::detail::expression_decomposer{} << expr); \
          LIBASSERT_WARNING_PRAGMA_POP \
 ...
```

https://github.com/jeremy-rifkin/libassert/blob/55d05fb987bea8d6080718dc6262b9cb8a8ad17b/include/assert.hpp

I apologize as I have not yet been able to create a minimal reproducible example yet
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to