r274713 - [CUDA] Fix "control reaches end of non-void function" warnings in Cuda.cpp.
Justin Lebar via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 6 18:07:00 PDT 2016
Author: jlebar
Date: Wed Jul 6 20:06:59 2016
New Revision: 274713
URL: http://llvm.org/viewvc/llvm-project?rev=274713&view=rev
Log:
[CUDA] Fix "control reaches end of non-void function" warnings in Cuda.cpp.
Some compilers are too dumb to realize that the switch statement covers
all cases.
(Don't use a "default" label, because we explicitly want to get a warning
if our switch doesn't cover all the cases.)
Modified:
cfe/trunk/lib/Basic/Cuda.cpp
Modified: cfe/trunk/lib/Basic/Cuda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Cuda.cpp?rev=274713&r1=274712&r2=274713&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Cuda.cpp (original)
+++ cfe/trunk/lib/Basic/Cuda.cpp Wed Jul 6 20:06:59 2016
@@ -2,6 +2,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ErrorHandling.h"
namespace clang {
@@ -16,6 +17,7 @@ const char *CudaVersionToString(CudaVers
case CudaVersion::CUDA_80:
return "8.0";
}
+ llvm_unreachable("invalid enum");
}
const char *CudaArchToString(CudaArch A) {
@@ -47,6 +49,7 @@ const char *CudaArchToString(CudaArch A)
case CudaArch::SM_62:
return "sm_62";
}
+ llvm_unreachable("invalid enum");
}
CudaArch StringToCudaArch(llvm::StringRef S) {
@@ -93,6 +96,7 @@ const char *CudaVirtualArchToString(Cuda
case CudaVirtualArch::COMPUTE_62:
return "compute_62";
}
+ llvm_unreachable("invalid enum");
}
CudaVirtualArch StringToCudaVirtualArch(llvm::StringRef S) {
@@ -139,6 +143,7 @@ CudaVirtualArch VirtualArchForCudaArch(C
case CudaArch::SM_62:
return CudaVirtualArch::COMPUTE_62;
}
+ llvm_unreachable("invalid enum");
}
CudaVersion MinVersionForCudaArch(CudaArch A) {
@@ -160,6 +165,7 @@ CudaVersion MinVersionForCudaArch(CudaAr
case CudaArch::SM_62:
return CudaVersion::CUDA_80;
}
+ llvm_unreachable("invalid enum");
}
} // namespace clang
More information about the cfe-commits
mailing list