[cfe-commits] r51907 - in /cfe/trunk: lib/AST/Expr.cpp test/Sema/gcc-cast-ext.m

Eli Friedman eli.friedman at gmail.com
Tue Jun 3 11:17:17 PDT 2008


On Tue, Jun 3, 2008 at 11:06 AM, Ted Kremenek <kremenek at apple.com> wrote:
>
> On Jun 3, 2008, at 10:54 AM, Steve Naroff wrote:
>
>>> This is no good: this potentially breaks standards-compliant code (as
>>> I said in reply to the mail you sent to cfe-dev), and it's completely
>>> impossible to warn for illegal cases.
>>
>> If Expr had access to langOptions(), why is this impossible to warn
>> about?
>
> Since an ASTContext& is passed to Expr::isIntegerConstantExpr, it seems that
> adding getLangOptions() to ASTContext would solve this problem. This
> wouldn't be that hard to do, since ASTContext is only constructed in a few
> places.

The issue is that we don't know whether it's an error until we're way
past isIntegerConstantExpr.  The flow is something like the following:
we see the array declarator, we query isIntegerConstantExpr as to
whether the expression is an ICE, then we construct either a
VariableArrayType or a ConstantArrayType depending on the result, this
constructed type gets passed back up to the field decl code, which
then decides that it doesn't like having a variable array type.
Handling this correctly in the middle of isIntegerConstantExpr
requires information that simply isn't there.

-Eli



More information about the cfe-commits mailing list