[PATCH] D69792: [NFC] Supress GCC "Bitfield too small to hold all values of enum" warning.
Wang Tianqing via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 4 02:04:32 PST 2019
tianqing created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
974c8b7e2fd introduced a warning for GCC:
llvm-project/clang/include/clang/Sema/Overload.h:835:48: warning: ‘clang::OverloadCandidate::RewriteKind’ is too small to hold all values of ‘enum clang::OverloadCandidateRewriteKind’
OverloadCandidateRewriteKind RewriteKind : 2;
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D69792
Files:
clang/include/clang/Sema/Overload.h
clang/lib/Sema/SemaOverload.cpp
Index: clang/lib/Sema/SemaOverload.cpp
===================================================================
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -9932,7 +9932,7 @@
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;
@@ -10502,8 +10502,8 @@
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
@@ -10621,8 +10621,8 @@
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
@@ -10632,7 +10632,7 @@
}
// 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;
}
@@ -10665,7 +10665,7 @@
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);
@@ -10676,7 +10676,7 @@
// 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:
Index: clang/include/clang/Sema/Overload.h
===================================================================
--- clang/include/clang/Sema/Overload.h
+++ clang/include/clang/Sema/Overload.h
@@ -821,7 +821,7 @@
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 @@
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 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69792.227662.patch
Type: text/x-patch
Size: 3758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191104/11fb1fac/attachment.bin>
More information about the cfe-commits
mailing list