[cfe-commits] r46152 - in /cfe/trunk: Sema/SemaDecl.cpp test/Sema/array-constraint.c test/Sema/deref.c test/Sema/enum.c test/Sema/incomplete-decl.c

Steve Naroff snaroff at apple.com
Fri Jan 18 17:03:07 PST 2008


On Jan 18, 2008, at 4:44 PM, Neil Booth wrote:

> Steve Naroff wrote:-
>
>> +struct foo f; // expected-error {{variable has incomplete type  
>> 'struct foo'}}
>
> Why do you think there is something inherently wrong with this?  In
> general you have to wait until the end of the TU.
>

You are correct.

To properly diagnose this, clang needs to check for incomplete types  
at the end of the translation unit.

I remember putting the following FIXME in SemaDecl.cpp:

/// FIXME: Need to carefully consider tentative definition rules (C99  
6.9.2p2).
/// For example, we incorrectly complain about i1, i4 from C99 6.9.2p4.

This requires a bit more API fiddling. For example, we need a  
ActOnEndTranslationUnit action, etc.

In fact, when I added the FIXME above, clang didn't even have the  
notion of a TranslationUnit:-)

snaroff

> struct foo x;
> struct foo { int x; };
>
> does not violate any rule in the standard I'm aware of, so must be
> accepted.
>
> /tmp/bug.c:1:12: error: variable has incomplete type 'struct foo'
> struct foo x;
>           ^
> 1 diagnostic generated.
>
> Neil.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20080118/062fa32e/attachment.html>


More information about the cfe-commits mailing list