[cfe-users] Clang compilation options to solve the comaptible issue?

2019-10-31 Thread Guofeng Zhang via cfe-users
Hi,

I just stat using clang 8 not long ago. I  need to compile our old c++
source without changing it. It is compiled with Visual Studio before. Now I
want to migrate to clang as the compiler.

The following code segement can be compiled by clang:

1)  for (int i = 0 ; i < 6 ; i++ ) {

 }
 int k = i ;  // compiler error

2) unsigned short *s = 
wchar_t  *t = s ; // compiler error

I tried -ffor-scope and -fshort-wchar, but does not solve the issues.

are there clang compilation options to solve the issues?

Thanks for your help very much,

Guofeng
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] does clang support option like MSVC's /Zc:forScope-

2019-10-31 Thread Guofeng Zhang via cfe-users
Hi,

In early versions of C++, the scope of a variable defined in a for loop
header extended to the end of the block containing the loop.

Is there way for clang to compile this old source?

Thanks,

Guofeng
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] Clang compilation options to solve the comaptible issue?

2019-11-06 Thread Guofeng Zhang via cfe-users
I just saw the mail today. It archived by gmail in the Sent folder.

Thanks for the helpful response.

On Mon, Nov 4, 2019 at 1:48 AM Richard Smith  wrote:

> On Thu, 31 Oct 2019 at 01:45, Guofeng Zhang via cfe-users <
> cfe-users@lists.llvm.org> wrote:
>
>> Hi,
>>
>> I just stat using clang 8 not long ago. I  need to compile our old c++
>> source without changing it. It is compiled with Visual Studio before. Now I
>> want to migrate to clang as the compiler.
>>
>> The following code segement can be compiled by clang:
>>
>> 1)  for (int i = 0 ; i < 6 ; i++ ) {
>> 
>>  }
>>  int k = i ;  // compiler error
>>
>
> This code is relying on pre-standard C++ for loop scoping behavior (the
> code has been invalid for all 21 years of standard C++). Clang does not
> support this pre-standard behavior.
>
>
>> 2) unsigned short *s = 
>> wchar_t  *t = s ; // compiler error
>>
>> I tried -ffor-scope and -fshort-wchar, but does not solve the issues.
>>
>> are there clang compilation options to solve the issues?
>>
>
> For the latter, something like "-Dwchar_t=unsigned short" might mostly
> work. (It won't support things like "wchar_t x = wchar_t(123);" though --
> to support that you could put "typedef unsigned short my_wchar_t; #define
> wchar_t my_wchar_t" into a -include'd header.)
>
> Generally. if you have the combination of ancient pre-standard C++ code
> that is invalid under any ISO C++ standard, and a requirement that you do
> not modify the code, you're going to have problems. Sorry. That said, Clang
> itself is open-source and modifiable, and it should be straightforward to
> add support for the above two constructs to Clang and build your own
> compiler that could perhaps accept this code. I'm not sure we'd want to
> accept patches for those non-standard behaviors upstream, though.
>
> Thanks for your help very much,
>>
>> Guofeng
>> ___
>> cfe-users mailing list
>> cfe-users@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>>
>
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Clang optimization options with out dead code elimination?

2019-12-19 Thread Guofeng Zhang via cfe-users
Hi,

We use clang 8+. Does clang have options (not -O0) that do not remove dead
code when clang optimize the code?

We have a old project, now migrating to Clang. It works well with -O0, but
failed when use -O1 to -O3.

Thanks,

Guofeng
___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users