From: Reid Kleckner Date: Fri, 14 Jun 2019 20:19:29 +0000 (+0000) Subject: Use unsigned for bitfields to avoid sign extension X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02d27f2c5293a9ddfc1a87a0f2a0cdd4c744b798;p=clang Use unsigned for bitfields to avoid sign extension git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363450 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h index 5c549d76aa..b417f89c0e 100644 --- a/include/clang/Sema/DeclSpec.h +++ b/include/clang/Sema/DeclSpec.h @@ -363,7 +363,7 @@ private: unsigned Friend_specified : 1; // constexpr-specifier - ConstexprSpecKind ConstexprSpecifier : 2; + unsigned ConstexprSpecifier : 2; union { UnionParsedType TypeRep; @@ -728,7 +728,10 @@ public: bool isModulePrivateSpecified() const { return ModulePrivateLoc.isValid(); } SourceLocation getModulePrivateSpecLoc() const { return ModulePrivateLoc; } - ConstexprSpecKind getConstexprSpecifier() const { return ConstexprSpecifier; } + ConstexprSpecKind getConstexprSpecifier() const { + return ConstexprSpecKind(ConstexprSpecifier); + } + SourceLocation getConstexprSpecLoc() const { return ConstexprLoc; } bool hasConstexprSpecifier() const { return ConstexprSpecifier != CSK_unspecified; diff --git a/lib/Sema/DeclSpec.cpp b/lib/Sema/DeclSpec.cpp index 21d7f6bd42..9433efb181 100644 --- a/lib/Sema/DeclSpec.cpp +++ b/lib/Sema/DeclSpec.cpp @@ -1037,9 +1037,9 @@ bool DeclSpec::setModulePrivateSpec(SourceLocation Loc, const char *&PrevSpec, bool DeclSpec::SetConstexprSpec(ConstexprSpecKind ConstexprKind, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID) { - if (ConstexprSpecifier != CSK_unspecified) { - if (ConstexprSpecifier == CSK_consteval || ConstexprKind == CSK_consteval) - return BadSpecifier(ConstexprKind, ConstexprSpecifier, PrevSpec, DiagID); + if (getConstexprSpecifier() != CSK_unspecified) { + if (getConstexprSpecifier() == CSK_consteval || ConstexprKind == CSK_consteval) + return BadSpecifier(ConstexprKind, getConstexprSpecifier(), PrevSpec, DiagID); DiagID = diag::warn_duplicate_declspec; PrevSpec = "constexpr"; return true;