[cfe-dev] Clang python bindings tests failing on Windows7/MSVC10

Evan P hiwrac at gmail.com
Mon Apr 16 11:00:05 PDT 2012


That makes sense.

I don't see anything in nosetests that specifies a platform, but we could
simply check for os.name == 'nt'  ( http://docs.python.org/library/os.html )
and check for TypeKind.INT on windows.

Thoughts?
-Evan

On Mon, Apr 16, 2012 at 10:41 AM, Matthieu Monrocq <
matthieu.monrocq at gmail.com> wrote:

>
>
> Le 16 avril 2012 11:08, Evan P <hiwrac at gmail.com> a écrit :
>
> When running the tests for the clang python bindings on windows 7 (x64,
>> clang built with MSVC 10).   This failure does not occur on Linux (Mint 12,
>> clang built with gcc 4.6.1)
>>
>>
>> ======================================================================
>>  FAIL: tests.cindex.test_cursor.test_enum_type
>> ----------------------------------------------------------------------
>> Traceback (most recent call last):
>>   File "C:\Python27\lib\site-packages\nose-1.1.2-py2.7.egg\nose\case.py",
>> line 1
>> 97, in runTest
>>     self.test(*self.arg)
>>   File
>> "E:\Dev\Projects\llvm\llvm\tools\clang\bindings\python\tests\cindex\test_
>> cursor.py", line 110, in test_enum_type
>>     assert enum_type.kind == TypeKind.UINT
>> AssertionError
>>
>>
>> The full test:
>>
>> def test_enum_type():
>>     tu = get_tu('enum TEST { FOO=1, BAR=2 };')
>>     enum = get_cursor(tu, 'TEST')
>>     assert enum is not None
>>
>>     assert enum.kind == CursorKind.ENUM_DECL
>>     enum_type = enum.enum_type
>>     assert enum_type.kind == TypeKind.UINT
>>
>> The assert is failing because the version compiled under MSVC
>> enum_type.kind is TypeKind.INT instead of TypeKind.UINT
>>
>> I see 2 possibilities, and I am not sure which is correct (possibly both):
>>
>> 1) This is simply an overzealous test, according to
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf (7.2.6)
>> (pg 156) an unscoped enum does not required a fixed type and can be any
>> integral type that can accommodate all enum values with the exception it is
>> not larger than int/unsigned int unless it has to be to  accommodate all
>> values.
>>
>> 2) There is an inconsistency in the way clang handles enum definitions
>> when built with MSVC10 vs GCC4.6.
>>
>> Can anyone shed some light on this, and point me in a direction to help
>> resolve this?
>>
>> Thanks
>> -Evan
>>
>>
>>
> I think it is an intentional inconsistency in the way Clang handles enums
> when generating code for enums.
>
> If I remember correctly gcc defaults to unsigned while MSVC defaults to
> int; Clang then just emulate their behavior in an attempt to be as close as
> possible to the code they emit.
>
> I do not know how to "force" the target triplet in python tests, but this
> is generally the way used to get a platform independent test.
>
> -- Matthieu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120416/41a0b44d/attachment.html>


More information about the cfe-dev mailing list