r274748 - Fix "not all control paths return a value" warning on MSVC

Sean Silva via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 7 12:54:23 PDT 2016


Btw we do have some advice for these situations in the programmer's manual:
http://llvm.org/docs/CodingStandards.html#don-t-use-default-labels-in-fully-covered-switches-over-enumerations

-- Sean Silva

On Thu, Jul 7, 2016 at 4:24 AM, Simon Pilgrim via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: rksimon
> Date: Thu Jul  7 06:24:38 2016
> New Revision: 274748
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274748&view=rev
> Log:
> Fix "not all control paths return a value" warning on MSVC
>
> This time without causing a 'all enums handled' warning on other compilers.
>
> Modified:
>     cfe/trunk/lib/Basic/Targets.cpp
>
> Modified: cfe/trunk/lib/Basic/Targets.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=274748&r1=274747&r2=274748&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Basic/Targets.cpp (original)
> +++ cfe/trunk/lib/Basic/Targets.cpp Thu Jul  7 06:24:38 2016
> @@ -1777,7 +1777,7 @@ public:
>        // Set __CUDA_ARCH__ for the GPU specified.
>        std::string CUDAArchCode = [this] {
>          switch (GPU) {
> -        case CudaArch::UNKNOWN:
> +        default:
>            assert(false && "No GPU arch when compiling CUDA device code.");
>            return "";
>          case CudaArch::SM_20:
> @@ -1804,8 +1804,6 @@ public:
>            return "610";
>          case CudaArch::SM_62:
>            return "620";
> -         default:
> -           llvm_unreachable("unhandled CudaArch");
>          }
>        }();
>        Builder.defineMacro("__CUDA_ARCH__", CUDAArchCode);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160707/b9c94329/attachment.html>


More information about the cfe-commits mailing list