[cfe-dev] Unneeded declarations invalidation

Douglas Gregor dgregor at apple.com
Tue Jul 21 09:28:01 PDT 2009


On Jul 21, 2009, at 7:58 AM, Abramo Bagnara wrote:

> Douglas Gregor ha scritto:
>>
>> It breaks the invariant that there are no variable-length structures,
>> which means that we can't compute sizeof(s). Since the well- 
>> formedness
>> (and, in C++, the AST itself) can depend on the value of sizeof(s),
>
> In C++ there are no problems, as also GCC refuses variable length  
> array
> inside records.

Okay. There's still GNU C code that can depend on the result of  
sizeof(s), and any attempt we make to give a fake size to "s" is  
likely to cause other code to fail later on.

>> later semantic analysis is likely to fail. We mark invalid  
>> declarations
>> as invalid to avoid such cascading failures.
>
> I understand... :-(
>
> Declaration invalidation apart, the removal of last statement of
> function f from AST is unavoidable for the same reasons?

Yes.

> The problem we have is to avoid that AST is missing some parts of what
> GCC is able to compile. Do you think it will be feasible in some way?
>
> Do you have some hints for a patch that you would be willing to accept
> to accomplish that?


I'm not sure how to proceed. Unfortunately, this is one of two GNU C  
extensions I can think of that Clang will *not* support (the other is  
nested functions), and I can't see any way to work around this  
limitation. Not having to worry about variable-length structures  
simplifies semantic analysis and other clients (CodeGen being the big  
one).

	- Doug



More information about the cfe-dev mailing list