r297654 - Widen bitfield for type specifiers for OpenCL types

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 13 11:42:30 PDT 2017


Author: rnk
Date: Mon Mar 13 13:42:30 2017
New Revision: 297654

URL: http://llvm.org/viewvc/llvm-project?rev=297654&view=rev
Log:
Widen bitfield for type specifiers for OpenCL types

Added a static_assert to catch this issue at compile time.

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

Modified: cfe/trunk/include/clang/Basic/Specifiers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Specifiers.h?rev=297654&r1=297653&r2=297654&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Specifiers.h (original)
+++ cfe/trunk/include/clang/Basic/Specifiers.h Mon Mar 13 13:42:30 2017
@@ -82,11 +82,12 @@ namespace clang {
   /// \brief Structure that packs information about the type specifiers that
   /// were written in a particular type specifier sequence.
   struct WrittenBuiltinSpecs {
-    /*DeclSpec::TST*/ unsigned Type  : 5;
+    static_assert(TST_error < 1 << 6, "Type bitfield not wide enough for TST");
+    /*DeclSpec::TST*/ unsigned Type  : 6;
     /*DeclSpec::TSS*/ unsigned Sign  : 2;
     /*DeclSpec::TSW*/ unsigned Width : 2;
     unsigned ModeAttr : 1;
-  };  
+  };
 
   /// \brief A C++ access specifier (public, private, protected), plus the
   /// special value "none" which means different things in different contexts.




More information about the cfe-commits mailing list