]> granicus.if.org Git - clang/commitdiff
Use unsigned for bitfields to avoid sign extension
authorReid Kleckner <rnk@google.com>
Fri, 14 Jun 2019 20:19:29 +0000 (20:19 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 14 Jun 2019 20:19:29 +0000 (20:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363450 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/DeclSpec.h
lib/Sema/DeclSpec.cpp

index 5c549d76aaf1171b3f63b56788db2d215eb8ef54..b417f89c0e5b60a2979c89adbb559c47c987e13c 100644 (file)
@@ -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;
index 21d7f6bd426ce99374d3f93a92ed7add4b4512e8..9433efb18194555399d999e30153ebf5c185c285 100644 (file)
@@ -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;