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

Prathamesh Kulkarni bilbotheelffriend at gmail.com
Mon Nov 10 04:16:27 PST 2014


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




More information about the cfe-dev mailing list