r338630 - [AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into DeclContext

Keane, Erich via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 6 05:57:01 PDT 2018


Hi, sorry for the delayed response, I only just got back into the office.  I've added the author of the patch to this email chain.

-----Original Message-----
From: Abramo Bagnara [mailto:abramo.bagnara at bugseng.com] 
Sent: Sunday, August 5, 2018 5:03 AM
To: Keane, Erich <erich.keane at intel.com>; cfe-commits at lists.llvm.org
Subject: Re: r338630 - [AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl into DeclContext

Il 01/08/2018 22:48, Erich Keane via cfe-commits ha scritto:
> Author: erichkeane
> Date: Wed Aug  1 13:48:16 2018
> New Revision: 338630
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=338630&view=rev
> Log:
> [AST][1/4] Move the bit-fields from TagDecl, EnumDecl and RecordDecl 
> into DeclContext
> 

This commit break the build with gcc version 7.3-win32 20180312 (GCC).

I've tracked the cause to the presence of:

enum { ObjCMethodFamilyBitWidth = 4 };

between two bitfields declarations.

Moving it to begin of class fix the build. This is spotted only because the static_assert, so it is well possible there are other occurrences of the same problem.

The following typescript show the issue:

abramo at igor:/tmp$ cat bad.cc
#include <cstdint>
enum { NumDeclContextBits = 13 };
class ObjCMethodDeclBitfields {
  uint64_t : NumDeclContextBits;
  enum { ObjCMethodFamilyBitWidth = 4 };
  mutable uint64_t Family : ObjCMethodFamilyBitWidth;
  uint64_t IsInstance : 1;
  uint64_t IsVariadic : 1;
  uint64_t IsPropertyAccessor : 1;
  uint64_t IsDefined : 1;
  uint64_t IsRedeclaration : 1;
  mutable uint64_t HasRedeclaration : 1;
  uint64_t DeclImplementation : 2;
  uint64_t objcDeclQualifier : 7;
  uint64_t RelatedResultType : 1;
  uint64_t SelLocsKind : 2;
  uint64_t IsOverriding : 1;
  uint64_t HasSkippedBody : 1;
};
static_assert(sizeof(ObjCMethodDeclBitfields) <= 8,
              "ObjCMethodDeclBitfields is larger than 8 bytes!"); abramo at igor:/tmp$ x86_64-w64-mingw32-g++ -c bad.cc
bad.cc:20:1: error: static assertion failed: ObjCMethodDeclBitfields is larger than 8 bytes!
 static_assert(sizeof(ObjCMethodDeclBitfields) <= 8,  ^~~~~~~~~~~~~
1|abramo at igor:/tmp$ cat good.cc
#include <cstdint>
enum { NumDeclContextBits = 13 };
class ObjCMethodDeclBitfields {
  enum { ObjCMethodFamilyBitWidth = 4 };
  uint64_t : NumDeclContextBits;
  mutable uint64_t Family : ObjCMethodFamilyBitWidth;
  uint64_t IsInstance : 1;
  uint64_t IsVariadic : 1;
  uint64_t IsPropertyAccessor : 1;
  uint64_t IsDefined : 1;
  uint64_t IsRedeclaration : 1;
  mutable uint64_t HasRedeclaration : 1;
  uint64_t DeclImplementation : 2;
  uint64_t objcDeclQualifier : 7;
  uint64_t RelatedResultType : 1;
  uint64_t SelLocsKind : 2;
  uint64_t IsOverriding : 1;
  uint64_t HasSkippedBody : 1;
};
static_assert(sizeof(ObjCMethodDeclBitfields) <= 8,
              "ObjCMethodDeclBitfields is larger than 8 bytes!"); abramo at igor:/tmp$ x86_64-w64-mingw32-g++ -c good.cc abramo at igor:/tmp$


--
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com


More information about the cfe-commits mailing list