Open llvmbot opened 4 years ago
Weird!
We have a special case diagnostic in Sema that rejects exactly this, dating back years:
if (isa<CXXScalarValueInitExpr>(RHS.get()->IgnoreParens())) {
// Diagnose use of pointer-to-member type which when used as
// the functional cast in a pointer-to-member expression.
Diag(Loc, diag::err_pointer_to_member_type) << isIndirect;
return QualType();
}
Added here: https://github.com/llvm/llvm-project/commit/1bc0f9affc20474dbf86842e2f38b00c844207c6
... as a refactoring of a diagnostic added here: https://github.com/llvm/llvm-project/commit/9a14b84ac559e85672ce9c463eba7bf23ba4b6a2
... to work around a bug in IR generation, as far as I can see.
Presumably we can downgrade this to a warning now :)
Simplifies to:
struct S {};
using FP = int S::*;
int main()
{
return S().*FP();
}
Somehow the parser isn't treating FP()
as an expression.
Still an error on post-17 trunk: https://godbolt.org/z/fPqxKdddx
@llvm/issue-subscribers-c-1
Extended Description
https://wandbox.org/permlink/ZjerOK6U3svPXXfE
This code will compile (and segfault) with gcc 10.1, but will not compile with clang 10.0.0. I think it's valid code. Playing with parentheses did not work for me.