================ @@ -2074,16 +2091,91 @@ static bool checkPointerAuthValue(Sema &S, Expr *&Arg, if (convertArgumentToType(S, Arg, ExpectedTy)) return true; - // Warn about null pointers for non-generic sign and auth operations. - if ((OpKind == PAO_Sign || OpKind == PAO_Auth) && - Arg->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNull)) { - S.Diag(Arg->getExprLoc(), OpKind == PAO_Sign - ? diag::warn_ptrauth_sign_null_pointer - : diag::warn_ptrauth_auth_null_pointer) - << Arg->getSourceRange(); + if (!RequireConstant) { + // Warn about null pointers for non-generic sign and auth operations. + if ((OpKind == PAO_Sign || OpKind == PAO_Auth) && + Arg->isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNull)) { + S.Diag(Arg->getExprLoc(), OpKind == PAO_Sign + ? diag::warn_ptrauth_sign_null_pointer + : diag::warn_ptrauth_auth_null_pointer) + << Arg->getSourceRange(); + } + + return false; } - return false; + // Perform special checking on the arguments to ptrauth_sign_constant. + + // The main argument. + if (OpKind == PAO_Sign) { + // Require the value we're signing to have a special form. + auto BaseOffsetPair = findConstantBaseAndOffset(S, Arg); + bool Invalid; + + // Must be rooted in a declaration reference. + if (!BaseOffsetPair.first) { + Invalid = true; ---------------- ahmedbougacha wrote:
Heh yeah, we can probably add more in the future, but TBH this is obscure enough that we can do it if asked https://github.com/llvm/llvm-project/pull/93904 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits