================ @@ -14644,6 +14644,17 @@ QualType Sema::CheckAddressOfOperand(ExprResult &OrigOp, SourceLocation OpLoc) { return QualType(); } + // C++11 [expr.unary.op] p4: + // A pointer to member is only formed when an explicit & is used and + // its operand is a qualified-id not enclosed in parentheses. + if (isa<ParenExpr>(OrigOp.get())) { + // `op->getEndLoc()` is the last part of the qualified-id. + // For example, "baz" in "foo::bar::baz". + Diag(op->getEndLoc(), diag::err_invalid_non_static_member_use) + << dcl->getDeclName() << op->getSourceRange(); ---------------- cor3ntin wrote:
Maybe we could have a more specific error, like "cannot form a pointer to member from a parenthesized expression" ? I would expect the error to point to the opening paren (`OrigOp->getBeginLoc()` presumably) https://github.com/llvm/llvm-project/pull/89713 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits