[cfe-dev] [PATCH] add constant expression evaluation to the AST and fix PR2413

Eli Friedman eli.friedman at gmail.com
Sun Jun 8 19:05:45 PDT 2008


Attached patch adds some capability to the AST to evaluate constant
expressions more general than integer constant expressions.  It then
uses that capability to remove the hack added for
Sema/darwin-align-cast.c, which fixes PR2413.

This is a significant chunk of code, but this appears to be the best
way to fix the original issue in a way which doesn't impact
correctness for valid code.  Some code like this is necessary anyway
to correctly honor 6.6p3 for Sema of initializer constant expressions.
 I imagine that the additional code could also be useful for external
consumers (as an alternative to the broken isConstantExpr()), and
possibly also for CodeGen (to reduce the number of codepaths
evaluating constant expressions).

The evaluation bits aren't complete, but they're enough to deal with
Sema/darwin-align-cast.c.  I'll probably do the rest incrementally.

As-is, this regresses CodeGen/struct-init.c, but I have a separate fix
for that which I'll commit soon.

I'm a bit tired right now, so I haven't reviewed this carefully myself
yet, but it appears to essentially work.  I'm sending it to the list
for general discussion, and so the only copy isn't on my computer.

-Eli
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: tt.txt
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080608/57085c2c/attachment.txt>


More information about the cfe-dev mailing list