r307483 - Fix build failure with gcc about mixing enum and non-enum

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Sat Jul 8 12:13:41 PDT 2017


Author: yaxunl
Date: Sat Jul  8 12:13:41 2017
New Revision: 307483

URL: http://llvm.org/viewvc/llvm-project?rev=307483&view=rev
Log:
Fix build failure with gcc about mixing enum and non-enum

Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=307483&r1=307482&r2=307483&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Jul  8 12:13:41 2017
@@ -2432,7 +2432,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
 
   auto ExpectedAS =
       D ? D->getType().getAddressSpace()
-        : (LangOpts.OpenCL ? LangAS::opencl_global : LangAS::Default);
+        : static_cast<unsigned>(LangOpts.OpenCL ? LangAS::opencl_global
+                                                : LangAS::Default);
   assert(getContext().getTargetAddressSpace(ExpectedAS) ==
          Ty->getPointerAddressSpace());
   if (AddrSpace != ExpectedAS)
@@ -2574,7 +2575,8 @@ CharUnits CodeGenModule::GetTargetTypeSt
 unsigned CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
   unsigned AddrSpace;
   if (LangOpts.OpenCL) {
-    AddrSpace = D ? D->getType().getAddressSpace() : LangAS::opencl_global;
+    AddrSpace = D ? D->getType().getAddressSpace()
+                  : static_cast<unsigned>(LangAS::opencl_global);
     assert(AddrSpace == LangAS::opencl_global ||
            AddrSpace == LangAS::opencl_constant ||
            AddrSpace == LangAS::opencl_local ||

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=307483&r1=307482&r2=307483&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Sat Jul  8 12:13:41 2017
@@ -421,7 +421,8 @@ unsigned TargetCodeGenInfo::getGlobalVar
   assert(!CGM.getLangOpts().OpenCL &&
          !(CGM.getLangOpts().CUDA && CGM.getLangOpts().CUDAIsDevice) &&
          "Address space agnostic languages only");
-  return D ? D->getType().getAddressSpace() : LangAS::Default;
+  return D ? D->getType().getAddressSpace()
+           : static_cast<unsigned>(LangAS::Default);
 }
 
 llvm::Value *TargetCodeGenInfo::performAddrSpaceCast(




More information about the cfe-commits mailing list