[cfe-dev] Patch to correctly determine when the address of a compound expression is constant

Eli Friedman eli.friedman at gmail.com
Tue Jan 8 16:43:56 PST 2008


> Patch fixes testcases like:
> static int *p = (int []){2, 4};
>
> and
>
> typedef struct Test {int a;int b;} Test;
> static Test* ll = &(Test) {0,0};
>
> so that they get through sema correctly.
>
> This patch fixes a few underlying issues:
>
> 1. It was previously not possible to determine (AFAIK) whether a
> CompoundLiteralExpr was file scope or not, so this patch propagates
> that information from the parser.  This is the biggest change, but is
> mostly mechanical.
> 2. It makes Expr::hasStaticStorage use that information when necessary.
> 3. It makes Expr::isConstantExpr deal with arrays that aren't
> declarations (currently, that's just compound literals).
> 4. It changes the order of the checks in Sema::CheckSingleInitializer
> so that any necessary implicit casts get added before checking for
> whether an initializer is constant.

Here's a current version of this patch; there were some recent changes
that caused merge conflicts.

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


More information about the cfe-dev mailing list