[cfe-dev] Type::isIncompleteType()...

Neil Booth neil at daikokuya.co.uk
Sun Feb 10 21:12:35 PST 2008


Steve Naroff wrote:-

> I tend to agree with you. If we make this change, the code below will  
> result in 2 errors. Note that both EDG & GCC only produce 1 error (the  
> first one). From my perspective, not flagging the 2nd error is  
> incorrect (though it could lead to some noisy diagnostics, I guess).
> 
> Neil, does your cfe produce 1 or 2 diagnostics for the following test  
> case?
> 
> snaroff
> 
> [steve-naroffs-imac:tools/clang/test] snaroff% cat xx.c
> struct S {
>   int a;
>   int foo();
> };
> 
> struct S s;
> 
> [steve-naroffs-imac:tools/clang/test] snaroff% ../../../Debug/bin/ 
> clang xx.c
> xx.c:3:7: error: field 'foo' declared as a function
>   int foo();
>       ^
> xx.c:6:10: error: variable has incomplete type 'struct S'
> struct S s;
>          ^
> 2 diagnostics generated.

$ ./cfe /tmp/bug.c
"/tmp/bug.c", line 3: error: members may not have function type
  int foo();
      ^

1 error found compiling "/tmp/bug.c".

I don't think it necessarily makes sense to expect extra diagnostics
in any particular situation; once something is erroneous there are
many reasonable recovery strategies.  I think my cfe just ignores
the foo declaration as if it didn't exist, for example.  Another
quite reasonable strategy would be to have a member foo in the
structure but flag it erroneous; this would mean uses of foo wouldn't
get diagnostics about no such member.

I'm not sure what the background is in this particular case.

Neil.



More information about the cfe-dev mailing list