[NFC] Supress GCC "Bitfield too small to hold all values of enum" warning.

Patch by Wang Tianqing!

Differential Revision: https://reviews.llvm.org/D69792
This commit is contained in:
Richard Smith 2019-11-09 05:52:18 -08:00
parent 2fb9d72c77
commit 56b5eab129
2 changed files with 15 additions and 9 deletions

View File

@ -821,7 +821,7 @@ class Sema;
CallExpr::ADLCallKind IsADLCandidate : 1;
/// Whether this is a rewritten candidate, and if so, of what kind?
OverloadCandidateRewriteKind RewriteKind : 2;
unsigned RewriteKind : 2;
/// FailureKind - The reason why this candidate is not viable.
/// Actually an OverloadFailureKind.
@ -841,6 +841,12 @@ class Sema;
StandardConversionSequence FinalConversion;
};
/// Get RewriteKind value in OverloadCandidateRewriteKind type (This
/// function is to workaround the spurious GCC bitfield enum warning)
OverloadCandidateRewriteKind getRewriteKind() const {
return static_cast<OverloadCandidateRewriteKind>(RewriteKind);
}
/// hasAmbiguousConversion - Returns whether this overload
/// candidate requires an ambiguous conversion or not.
bool hasAmbiguousConversion() const {

View File

@ -9935,7 +9935,7 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand,
std::string FnDesc;
std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->RewriteKind,
ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->getRewriteKind(),
FnDesc);
Expr *FromExpr = Conv.Bad.FromExpr;
@ -10505,8 +10505,8 @@ static void DiagnoseBadTarget(Sema &S, OverloadCandidate *Cand) {
std::string FnDesc;
std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee, Cand->RewriteKind,
FnDesc);
ClassifyOverloadCandidate(S, Cand->FoundDecl, Callee,
Cand->getRewriteKind(), FnDesc);
S.Diag(Callee->getLocation(), diag::note_ovl_candidate_bad_target)
<< (unsigned)FnKindPair.first << (unsigned)ocs_non_template
@ -10624,8 +10624,8 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
if (Fn->isDeleted()) {
std::string FnDesc;
std::pair<OverloadCandidateKind, OverloadCandidateSelect> FnKindPair =
ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn, Cand->RewriteKind,
FnDesc);
ClassifyOverloadCandidate(S, Cand->FoundDecl, Fn,
Cand->getRewriteKind(), FnDesc);
S.Diag(Fn->getLocation(), diag::note_ovl_candidate_deleted)
<< (unsigned)FnKindPair.first << (unsigned)FnKindPair.second << FnDesc
@ -10635,7 +10635,7 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
}
// We don't really have anything else to say about viable candidates.
S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->getRewriteKind());
return;
}
@ -10668,7 +10668,7 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
case ovl_fail_trivial_conversion:
case ovl_fail_bad_final_conversion:
case ovl_fail_final_conversion_not_exact:
return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->getRewriteKind());
case ovl_fail_bad_conversion: {
unsigned I = (Cand->IgnoreObjectArgument ? 1 : 0);
@ -10679,7 +10679,7 @@ static void NoteFunctionCandidate(Sema &S, OverloadCandidate *Cand,
// FIXME: this currently happens when we're called from SemaInit
// when user-conversion overload fails. Figure out how to handle
// those conditions and diagnose them well.
return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->RewriteKind);
return S.NoteOverloadCandidate(Cand->FoundDecl, Fn, Cand->getRewriteKind());
}
case ovl_fail_bad_target: