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

Steve Naroff snaroff at apple.com
Wed Jan 9 13:08:59 PST 2008


Eli,

Thanks for your patch...nice work. Comments below...

On Jan 8, 2008, at 4:43 PM, Eli Friedman wrote:

>> 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.

I'd prefer we avoid changing the API or AST.

I just submitted a small patch (r45782) that allows sema to detect  
when constant expressions are required.

For now, I'd recommend a smaller, focused patch to deal with the  
following (which my commit doesn't address)...

>> typedef struct Test {int a;int b;} Test;
>> static Test* ll = &(Test) {0,0};

Can you resubmit a patch that builds on r45782?

Thanks,

snaroff

>>
>> 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
> < 
> arrayconversionfixfull 
> .txt>_______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev




More information about the cfe-dev mailing list