[cfe-dev] -Wc++-compat doesn't warn for C++ keywords and nested structs

Richard Smith richard at metafoo.co.uk
Wed Nov 19 17:53:26 PST 2014


On Fri, Nov 14, 2014 at 2:08 PM, Prathamesh Kulkarni <
bilbotheelffriend at gmail.com> wrote:

> It appears diagnostic for assignment from void * is also missed.
>

Please report this and any other cases on the bug; messages here are likely
to be forgotten about.


> Test-case:
> int main(void)
> {
>   void *q = 0;
>   int *p;
>   p = q;
>   return 0;
> }
>
> gcc -fsyntax-only -Wc++-compat prints:
> void-ptr-cast.c:5:5: warning: request for implicit conversion from
> ‘void *’ to ‘int *’ not permitted in C++ [-Wc++-compat]
>    p = q;
>      ^
>
> Thank you,
> Prathamesh
>
>
>
>
>
> On Tue, Nov 11, 2014 at 9:07 AM, Richard Smith <richard at metafoo.co.uk>
> wrote:
> > Filed as llvm.org/PR21524
> >
> > On Mon, Nov 10, 2014 at 4:16 AM, Prathamesh Kulkarni
> > <bilbotheelffriend at gmail.com> wrote:
> >>
> >> Hi,
> >>   clang doesn't print warning for following test-case:
> >> compiled with: clang -fsyntax-only -Wc++-compat
> >>
> >> int new;
> >> struct A
> >> {
> >>   struct B
> >>   {
> >>     int x;
> >>   }bs;
> >>   int y;
> >> };
> >> struct B b;
> >>
> >>
> >> gcc -fsyntax-only -Wc++-compat prints following warnings (gcc-4.9.1
> >> ubuntu):
> >>
> >> t.c:1:5: warning: identifier ‘new’ conflicts with C++ keyword
> >> [-Wc++-compat]
> >>  int new;
> >>       ^
> >> t.c:13:8: warning: struct defined in struct or union is not visible in
> >> C++ [-Wc++-compat]
> >>  struct B b;
> >>            ^
> >> t.c:5:10: note: struct defined here
> >>    struct B
> >>              ^
> >> clang --version:
> >> Ubuntu clang version 3.5.0-4ubuntu2 (tags/RELEASE_350/final) (based on
> >> LLVM 3.5.0)
> >> Target: x86_64-pc-linux-gnu
> >> Thread model: posix
> >>
> >> Thank you,
> >> Prathamesh
> >>
> >> _______________________________________________
> >> cfe-dev mailing list
> >> cfe-dev at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141119/d7100cc4/attachment.html>


More information about the cfe-dev mailing list