[clang] [clang] pointer to member with qualified-id enclosed in parentheses in unevaluated context should be invalid (PR #89713)

Hubert Tong via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 17 12:12:04 PDT 2024


hubert-reinterpretcast wrote:

I think (at least part of) the fix is to add a condition to

https://github.com/llvm/llvm-project/blob/21e6777957457451196084cd48ebc42bce9619f0/clang/lib/Sema/SemaExpr.cpp#L14117-L14120

that the operand is not parenthesized. For reference, the address-of-member-function case checks for parentheses this way:

https://github.com/llvm/llvm-project/blob/21e6777957457451196084cd48ebc42bce9619f0/clang/lib/Sema/SemaExpr.cpp#L13908-L13912

This should address the pre-existing bug with:
```cpp
namespace std {
  template <typename, typename>
  struct is_same { static constexpr bool value = false; };

  template <typename T>
  struct is_same<T, T> { static constexpr bool value = true; };
}
 
struct S {
    int &x;
    static_assert(std::is_same<decltype(&(S::x)), int *>::value, "");
};
```

https://github.com/llvm/llvm-project/pull/89713


More information about the cfe-commits mailing list