[cfe-dev] Warnings from macro expansions vs system headers

Sean McBride sean at rogue-research.com
Thu Nov 8 14:15:32 PST 2012


Hi all,

Is it expected that I get a warning from this, since the macro expansion happens in my source file, despite the "buggy" macro contents being in a system header?  (I filed <rdar://12665902> against the header regardless BTW.)

---------------
#include <IOKit/IOReturn.h>

int main (void)
{
	IOReturn ioReturnValue = kIOReturnExclusiveAccess;

	return 0;
}
---------------


clang -Wshift-sign-overflow -fsyntax-only ~/Desktop/test.c


/Users/sean/Desktop/test.c:5:27: warning: signed shift result (0xE0000000) sets the sign bit of the shift expression's type ('int') and becomes negative [-Wshift-sign-overflow]
        IOReturn ioReturnValue = kIOReturnExclusiveAccess;
                                 ^~~~~~~~~~~~~~~~~~~~~~~~
/System/Library/Frameworks/IOKit.framework/Headers/IOReturn.h:84:34: note: expanded from macro 'kIOReturnExclusiveAccess'
#define kIOReturnExclusiveAccess iokit_common_err(0x2c5) // exclusive access and
                                 ^
/System/Library/Frameworks/IOKit.framework/Headers/IOReturn.h:70:44: note: expanded from macro 'iokit_common_err'
#define iokit_common_err(return)          (sys_iokit|sub_iokit_common|return)
                                           ^
/System/Library/Frameworks/IOKit.framework/Headers/IOReturn.h:48:43: note: expanded from macro 'sys_iokit'
#define sys_iokit                         err_system(0x38)
                                          ^
/usr/include/mach/error.h:83:35: note: expanded from macro 'err_system'
#define err_system(x)           (((x)&0x3f)<<26)
                                 ~~~~~~~~~~^ ~~

Thanks,

Sean






More information about the cfe-dev mailing list