[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; CallExpr::ADLCallKind IsADLCandidate : 1;
/// Whether this is a rewritten candidate, and if so, of what kind? /// 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. /// FailureKind - The reason why this candidate is not viable.
/// Actually an OverloadFailureKind. /// Actually an OverloadFailureKind.
@ -841,6 +841,12 @@ class Sema;
StandardConversionSequence FinalConversion; 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 /// hasAmbiguousConversion - Returns whether this overload
/// candidate requires an ambiguous conversion or not. /// candidate requires an ambiguous conversion or not.
bool hasAmbiguousConversion() const { bool hasAmbiguousConversion() const {

View File

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