<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Argiris,<div><br class="webkit-block-placeholder"></div><div>I just applied this and your last patch (modulo some edits to some comments to wrap two lines at 80 cols):</div><div><br class="webkit-block-placeholder"></div><div><a href="http://llvm.org/viewvc/llvm-project?rev=47536&view=rev">http://llvm.org/viewvc/llvm-project?rev=47536&view=rev</a></div><div><br class="webkit-block-placeholder"></div><div>Thanks so much!</div><div><br class="webkit-block-placeholder"></div><div>Ted</div><div><br><div><div>On Feb 23, 2008, at 4:15 PM, Argiris Kirtzidis wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi,<br><br>The attached patch, changes enum bitfields to "unsigned", to avoid getting<br>negative values because MSVC treats them as signed variables.<br>Index: include/clang/AST/Decl.h<br>===================================================================<br>--- include/clang/AST/Decl.h<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 47533)<br>+++ include/clang/AST/Decl.h<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)<br>@@ -408,7 +408,9 @@<br> : VarDecl(ParmVar, L, Id, T, S, PrevDecl), <br> objcDeclQualifier(OBJC_TQ_None) {}<br><br>- ObjCDeclQualifier getObjCDeclQualifier() const { return objcDeclQualifier; }<br>+ ObjCDeclQualifier getObjCDeclQualifier() const {<br>+ return ObjCDeclQualifier(objcDeclQualifier);<br>+ }<br> void setObjCDeclQualifier(ObjCDeclQualifier QTVal) <br> { objcDeclQualifier = QTVal; }<br><br>@@ -417,9 +419,10 @@<br> static bool classof(const ParmVarDecl *D) { return true; }<br><br> private:<br>+ // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum<br> /// FIXME: Also can be paced into the bitfields in Decl.<br> /// in, inout, etc.<br>- ObjCDeclQualifier objcDeclQualifier : 6;<br>+ unsigned objcDeclQualifier : 6;<br><br> protected:<br> /// EmitImpl - Serialize this ParmVarDecl. Called by Decl::Emit.<br>@@ -474,7 +477,7 @@<br> QualType getResultType() const { <br> return cast<FunctionType>(getType())->getResultType();<br> }<br>- StorageClass getStorageClass() const { return SClass; }<br>+ StorageClass getStorageClass() const { return StorageClass(SClass); }<br> bool isInline() const { return IsInline; }<br><br> // Implement isa/cast/dyncast/etc.<br>@@ -494,7 +497,8 @@<br> /// function.<br> ScopedDecl *DeclChain;<br><br>- StorageClass SClass : 2;<br>+ // NOTE: VC++ treats enums as signed, avoid using the StorageClass enum<br>+ unsigned SClass : 2;<br> bool IsInline : 1;<br><br> protected:<br>Index: include/clang/AST/DeclObjC.h<br>===================================================================<br>--- include/clang/AST/DeclObjC.h<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 47533)<br>+++ include/clang/AST/DeclObjC.h<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)<br>@@ -58,11 +58,13 @@<br> bool IsInstance : 1;<br> bool IsVariadic : 1;<br><br>+ // NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum<br> /// @required/@optional<br>- ImplementationControl DeclImplementation : 2;<br>+ unsigned DeclImplementation : 2;<br><br>+ // NOTE: VC++ treats enums as signed, avoid using the ObjCDeclQualifier enum<br> /// in, inout, etc.<br>- ObjCDeclQualifier objcDeclQualifier : 6;<br>+ unsigned objcDeclQualifier : 6;<br><br> // Context this method is declared in.<br> NamedDecl *MethodContext;<br>@@ -104,7 +106,9 @@<br> MethodAttrs(M), EndLoc(endLoc), Body(0), SelfDecl(0) {}<br> virtual ~ObjCMethodDecl();<br><br>- ObjCDeclQualifier getObjCDeclQualifier() const { return objcDeclQualifier; }<br>+ ObjCDeclQualifier getObjCDeclQualifier() const {<br>+ return ObjCDeclQualifier(objcDeclQualifier);<br>+ }<br> void setObjCDeclQualifier(ObjCDeclQualifier QV) { objcDeclQualifier = QV; }<br><br> // Location information, modeled after the Stmt API.<br>@@ -149,7 +153,7 @@<br> DeclImplementation = ic; <br> }<br> ImplementationControl getImplementationControl() const { <br>- return DeclImplementation; <br>+ return ImplementationControl(DeclImplementation); <br> }<br> Stmt *const getBody() const { return Body; }<br> void setBody(Stmt *B) { Body = B; }<br>@@ -365,13 +369,14 @@<br> None, Private, Protected, Public, Package<br> };<br> void setAccessControl(AccessControl ac) { DeclAccess = ac; }<br>- AccessControl getAccessControl() const { return DeclAccess; }<br>+ AccessControl getAccessControl() const { return AccessControl(DeclAccess); }<br><br> // Implement isa/cast/dyncast/etc.<br> static bool classof(const Decl *D) { return D->getKind() == ObjCIvar; }<br> static bool classof(const ObjCIvarDecl *D) { return true; }<br> private:<br>- AccessControl DeclAccess : 3;<br>+ // NOTE: VC++ treats enums as signed, avoid using the AccessControl enum<br>+ unsigned DeclAccess : 3;<br> };<br><br><br>@@ -873,9 +878,10 @@<br> // FIXME: Property is not an ivar.<br> ObjCIvarDecl **PropertyDecls;<br> int NumPropertyDecls;<br>+<br>+ // NOTE: VC++ treats enums as signed, avoid using PropertyAttributeKind enum<br>+ unsigned PropertyAttributes : 8;<br><br>- PropertyAttributeKind PropertyAttributes : 8;<br>- <br> IdentifierInfo *GetterName; // getter name of NULL if no getter<br> IdentifierInfo *SetterName; // setter name of NULL if no setter<br><br>@@ -892,7 +898,7 @@<br> void setNumPropertyDecls(int num) { NumPropertyDecls = num; }<br><br> const PropertyAttributeKind getPropertyAttributes() const <br>- { return PropertyAttributes; }<br>+ { return PropertyAttributeKind(PropertyAttributes); }<br> void setPropertyAttributes(PropertyAttributeKind PRVal) { <br> PropertyAttributes = <br> (PropertyAttributeKind) (PropertyAttributes | PRVal);<br>Index: include/clang/AST/Type.h<br>===================================================================<br>--- include/clang/AST/Type.h<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 47533)<br>+++ include/clang/AST/Type.h<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)<br>@@ -552,8 +552,9 @@<br> /// ElementType - The element type of the array.<br> QualType ElementType;<br><br>+ // NOTE: VC++ treats enums as signed, avoid using the ArraySizeModifier enum<br> /// NOTE: These fields are packed into the bitfields space in the Type class.<br>- ArraySizeModifier SizeModifier : 2;<br>+ unsigned SizeModifier : 2;<br><br> /// IndexTypeQuals - Capture qualifiers in declarations like:<br> /// 'int X[static restrict 4]'. For function parameters only.<br>@@ -566,7 +567,9 @@<br> friend class ASTContext; // ASTContext creates these.<br> public:<br> QualType getElementType() const { return ElementType; }<br>- ArraySizeModifier getSizeModifier() const { return SizeModifier; }<br>+ ArraySizeModifier getSizeModifier() const {<br>+ return ArraySizeModifier(SizeModifier);<br>+ }<br> unsigned getIndexTypeQualifier() const { return IndexTypeQuals; }<br><br> QualType getBaseType() const {<br>Index: include/clang/Basic/IdentifierTable.h<br>===================================================================<br>--- include/clang/Basic/IdentifierTable.h<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 47533)<br>+++ include/clang/Basic/IdentifierTable.h<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)<br>@@ -40,7 +40,8 @@<br> // signed char and TokenKinds > 127 won't be handled correctly.<br> unsigned TokenID : 8; // Front-end token ID or tok::identifier. <br> unsigned BuiltinID : 9; // ID if this is a builtin (__builtin_inf).<br>- tok::ObjCKeywordKind ObjCID : 5; // ID for objc @ keyword like @'protocol'.<br>+ // NOTE: VC++ treats enums as signed, avoid using tok::ObjCKeywordKind enum<br>+ unsigned ObjCID : 5; // ID for objc @ keyword like @'protocol'.<br> bool HasMacro : 1; // True if there is a #define for this.<br> bool IsExtension : 1; // True if identifier is a lang extension.<br> bool IsPoisoned : 1; // True if identifier is poisoned.<br>@@ -91,7 +92,9 @@<br> /// getObjCKeywordID - Return the Objective-C keyword ID for the this<br> /// identifier. For example, 'class' will return tok::objc_class if ObjC is<br> /// enabled.<br>- tok::ObjCKeywordKind getObjCKeywordID() const { return ObjCID; }<br>+ tok::ObjCKeywordKind getObjCKeywordID() const {<br>+ return tok::ObjCKeywordKind(ObjCID);<br>+ }<br> void setObjCKeywordID(tok::ObjCKeywordKind ID) { ObjCID = ID; }<br><br> /// getBuiltinID - Return a value indicating whether this is a builtin<br>Index: include/clang/Lex/DirectoryLookup.h<br>===================================================================<br>--- include/clang/Lex/DirectoryLookup.h<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 47533)<br>+++ include/clang/Lex/DirectoryLookup.h<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)<br>@@ -48,9 +48,10 @@<br> const HeaderMap *Map;<br> } u;<br><br>+ // NOTE: VC++ treats enums as signed, avoid using the DirType enum<br> /// DirCharacteristic - The type of directory this is, one of the DirType enum<br> /// values.<br>- DirType DirCharacteristic : 2;<br>+ unsigned DirCharacteristic : 2;<br><br> /// UserSupplied - True if this is a user-supplied directory.<br> ///<br>@@ -110,7 +111,7 @@<br><br> /// DirCharacteristic - The type of directory this is, one of the DirType enum<br> /// values.<br>- DirType getDirCharacteristic() const { return DirCharacteristic; }<br>+ DirType getDirCharacteristic() const { return DirType(DirCharacteristic); }<br><br> /// isUserSupplied - True if this is a user-supplied directory.<br> ///<br>Index: include/clang/Lex/HeaderSearch.h<br>===================================================================<br>--- include/clang/Lex/HeaderSearch.h<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 47533)<br>+++ include/clang/Lex/HeaderSearch.h<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)<br>@@ -45,10 +45,11 @@<br> /// isImport - True if this is a #import'd or #pragma once file.<br> bool isImport : 1;<br><br>+ // NOTE: VC++ treats enums as signed, avoid using DirectoryLookup::DirType<br> /// DirInfo - Keep track of whether this is a system header, and if so,<br> /// whether it is C++ clean or not. This can be set by the include paths or<br> /// by #pragma gcc system_header.<br>- DirectoryLookup::DirType DirInfo : 2;<br>+ unsigned DirInfo : 2;<br><br> /// NumIncludes - This is the number of times the file has been included<br> /// already.<br>@@ -155,7 +156,7 @@<br> /// getFileDirFlavor - Return whether the specified file is a normal header,<br> /// a system header, or a C++ friendly system header.<br> DirectoryLookup::DirType getFileDirFlavor(const FileEntry *File) {<br>- return getFileInfo(File).DirInfo;<br>+ return DirectoryLookup::DirType(getFileInfo(File).DirInfo);<br> }<br><br> /// MarkFileIncludeOnce - Mark the specified file as a "once only" file, e.g.<br>Index: include/clang/Parse/DeclSpec.h<br>===================================================================<br>--- include/clang/Parse/DeclSpec.h<span class="Apple-tab-span" style="white-space:pre"> </span>(revision 47533)<br>+++ include/clang/Parse/DeclSpec.h<span class="Apple-tab-span" style="white-space:pre"> </span>(working copy)<br>@@ -330,7 +330,7 @@<br> { objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier | DQVal); }<br><br> const ObjCPropertyAttributeKind getPropertyAttributes() const <br>- { return PropertyAttributes; }<br>+ { return ObjCPropertyAttributeKind(PropertyAttributes); }<br> void setPropertyAttributes(ObjCPropertyAttributeKind PRVal) { <br> PropertyAttributes = <br> (ObjCPropertyAttributeKind) (PropertyAttributes | PRVal);<br>@@ -349,7 +349,8 @@<br> // (space saving is negligible).<br> ObjCDeclQualifier objcDeclQualifier : 6;<br><br>- ObjCPropertyAttributeKind PropertyAttributes : 8;<br>+ // NOTE: VC++ treats enums as signed, avoid using ObjCPropertyAttributeKind<br>+ unsigned PropertyAttributes : 8;<br> IdentifierInfo *GetterName; // getter name of NULL if no getter<br> IdentifierInfo *SetterName; // setter name of NULL if no setter<br> };<br><span><enum-bitfields-fix.zip></span>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev<br></blockquote></div><br></div></body></html>