[llvm-dev] __auto_type doesn't warn when a pointer is used as a declarator

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[llvm-dev] __auto_type doesn't warn when a pointer is used as a declarator

Gerolf Hoflehner via llvm-dev
Hi,

__auto_type *p = (int *) 0;

This compiles with no problem, but GCC gives an error that we can only use plain identifier as a declarator. 

Please confirm if clang behavior is valid. 

Thanks in advance,
Best regards,
Puneetha

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] __auto_type doesn't warn when a pointer is used as a declarator

Gerolf Hoflehner via llvm-dev
On 9 June 2017 at 02:07, Puneetha K via llvm-dev
<[hidden email]> wrote:
> __auto_type *p = (int *) 0;
>
> This compiles with no problem, but GCC gives an error that we can only use
> plain identifier as a declarator.

At the very least Clang's behaviour is consistent with "auto" in C++,
which I think is a good thing.

Tim.
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] [cfe-dev] __auto_type doesn't warn when a pointer is used as a declarator

Gerolf Hoflehner via llvm-dev
On 9 June 2017 at 07:13, Tim Northover via cfe-dev <[hidden email]> wrote:
On 9 June 2017 at 02:07, Puneetha K via llvm-dev
<[hidden email]> wrote:
> __auto_type *p = (int *) 0;
>
> This compiles with no problem, but GCC gives an error that we can only use
> plain identifier as a declarator.

At the very least Clang's behaviour is consistent with "auto" in C++,
which I think is a good thing.

If someone wanted to put a patch together, it would seem reasonable to issue a -Wgcc-compat warning on cases that we know GCC rejects. (We also don't quite follow the GCC semantics: per GCC's documentation, an __auto_type variable is not in scope in its own initializer, whereas Clang's approach makes it an error to name the variable within its initializer, like 'auto' in C++. But at least that means we reject a superset of what GCC rejects.)

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Loading...