]> granicus.if.org Git - clang/commitdiff
Widen bitfield for type specifiers for OpenCL types
authorReid Kleckner <rnk@google.com>
Mon, 13 Mar 2017 18:42:30 +0000 (18:42 +0000)
committerReid Kleckner <rnk@google.com>
Mon, 13 Mar 2017 18:42:30 +0000 (18:42 +0000)
Added a static_assert to catch this issue at compile time.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@297654 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Specifiers.h

index 369a36f3dca623396460a7b5c9e58fd7ab30e532..33952f83ff23a5d62881430be89a92a4a76e5bcf 100644 (file)
@@ -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.