r305439 - [Basic] Use a static_assert instead of using the old array of size -1 trick.

Craig Topper via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 14 18:27:58 PDT 2017


Author: ctopper
Date: Wed Jun 14 20:27:58 2017
New Revision: 305439

URL: http://llvm.org/viewvc/llvm-project?rev=305439&view=rev
Log:
[Basic] Use a static_assert instead of using the old array of size -1 trick.

Modified:
    cfe/trunk/include/clang/Basic/AllDiagnostics.h

Modified: cfe/trunk/include/clang/Basic/AllDiagnostics.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AllDiagnostics.h?rev=305439&r1=305438&r2=305439&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/AllDiagnostics.h (original)
+++ cfe/trunk/include/clang/Basic/AllDiagnostics.h Wed Jun 14 20:27:58 2017
@@ -28,7 +28,7 @@
 namespace clang {
 template <size_t SizeOfStr, typename FieldType>
 class StringSizerHelper {
-  char FIELD_TOO_SMALL[SizeOfStr <= FieldType(~0U) ? 1 : -1];
+  static_assert(SizeOfStr <= FieldType(~0U), "Field too small!");
 public:
   enum { Size = SizeOfStr };
 };




More information about the cfe-commits mailing list