Tentatively apply https://reviews.llvm.org/D23921, to get rid of false
positive diagnostics from -Wvarargs about enum parameters, e.g.: cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c:388:15: error: passing an object that undergoes default argument promotion to 'va_start' has undefined behavior [-Werror,-Wvarargs] va_start(ap, which); ^ cddl/contrib/opensolaris/lib/libnvpair/libnvpair.c:382:66: note: parameter of type 'enum nvlist_prtctl_fmt' is declared here nvlist_prtctl_dofmt(nvlist_prtctl_t pctl, enum nvlist_prtctl_fmt which, ...) ^
This commit is contained in:
parent
aeb74474a8
commit
57497b8693
@ -3189,8 +3189,17 @@ bool Sema::SemaBuiltinVAStartImpl(CallExpr *TheCall) {
|
||||
Diag(TheCall->getArg(1)->getLocStart(),
|
||||
diag::warn_second_arg_of_va_start_not_last_named_param);
|
||||
else if (IsCRegister || Type->isReferenceType() ||
|
||||
Type->isPromotableIntegerType() ||
|
||||
Type->isSpecificBuiltinType(BuiltinType::Float)) {
|
||||
Type->isSpecificBuiltinType(BuiltinType::Float) || [=] {
|
||||
// Promotable integers are UB, but enumerations need a bit of
|
||||
// extra checking to see what their promotable type actually is.
|
||||
if (!Type->isPromotableIntegerType())
|
||||
return false;
|
||||
if (!Type->isEnumeralType())
|
||||
return true;
|
||||
const EnumDecl *ED = Type->getAs<EnumType>()->getDecl();
|
||||
return !(ED &&
|
||||
Context.typesAreCompatible(ED->getPromotionType(), Type));
|
||||
}()) {
|
||||
unsigned Reason = 0;
|
||||
if (Type->isReferenceType()) Reason = 1;
|
||||
else if (IsCRegister) Reason = 2;
|
||||
|
Loading…
x
Reference in New Issue
Block a user