llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.46k forks source link

[ms compat] compilation of spec2000: `255.vortex` is failing with `typedef` redefinition #26608

Open llvmbot opened 8 years ago

llvmbot commented 8 years ago
Bugzilla Link 26234
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @majnemer,@DougGregor

Extended Description

==========Environment============ OS: Windows Visual Studio: VS2015 Clang: trunk

=========How to reproduce========

//this lines were taken from spec2000: 255.vortex
//now it is failed to be compiled with clang 
#include <windows.h>
typedef size_t SIZE_T;
$ clang test.cpp -c -m32

=========Error===================

test.cpp:2:16: error: typedef redefinition with different types ('size_t' (aka 'unsigned int') vs 'ULONG_PTR'
      (aka 'unsigned long'))
typedef size_t SIZE_T;
               ^
c:/Program files (x86)/Windows Kits/8.1/include/shared/basetsd.h:415:19: note: previous definition is here
typedef ULONG_PTR SIZE_T, *PSIZE_T;
                  ^

================== Intel Compiler Engineer Kuleshov Andrey

llvmbot commented 8 years ago

Fix has been sent for review (http://reviews.llvm.org/D16770).

Denis Zobnin

Software Engineer Intel Compiler Team Intel

llvmbot commented 8 years ago

I will handle this.

Denis Zobnin

Software Engineer Intel Compiler Team Intel

991901f3-cc14-4404-b340-165691b62a58 commented 8 years ago

A-ha, this is a C vs C++ issue.

MSVC accepts this in C mode.

991901f3-cc14-4404-b340-165691b62a58 commented 8 years ago

Hrm, VS2013 fails for me:

D:\>type t.cpp
#include <windows.h>
typedef size_t SIZE_T;
D:\>cl -c t.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

t.cpp
t.cpp(2) : error C2371: 'SIZE_T' : redefinition; different basic types
        C:\Program Files (x86)\Windows Kits\8.1\include\shared\basetsd.h(415) : see declaration of 'SIZE_T'
llvmbot commented 8 years ago

MSVC 2015 Compiler version: 19.00.23720.0(x86) reports the following for me: error C2371: 'SIZE_T': redefinition; different basic types c:\tools_root\cl\inc\shared\basetsd.h(415): note: see declaration of 'SIZE_T'

Seems like our behavior is the same as MSVC's.

Yep, seems that I was using VS2013:

$ cl -c test.c 
Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86
Copyright (C) Microsoft Corporation.  All rights reserved.

test.c
test.c(2) : warning C4142: benign redefinition of type 

I will try it with VS2015 as sonn as possible, but anyway, do we need to change Clang's behavior to be able to compile spec2000 with it?

991901f3-cc14-4404-b340-165691b62a58 commented 8 years ago

MSVC 2015 Compiler version: 19.00.23720.0(x86) reports the following for me:

error C2371: 'SIZE_T': redefinition; different basic types
c:\tools_root\cl\inc\shared\basetsd.h(415): note: see declaration of 'SIZE_T'

Seems like our behavior is the same as MSVC's.