On Feb 4, 2008, at 3:59 PM, Eli Friedman wrote:
> On Feb 4, 2008 3:06 PM, Steve Naroff <[EMAIL PROTECTED]> wrote:
>> One solution is to extend Expr::isModifiableLvalue() and the
>> MemberExpr AST to return the underlying base type.
>
> That might fix this exact case, but it's not a general fix. Try
> something like the following:
> int a(const struct {int a;} * x) {
> int* y = &x->a;
> *y = 10;
> }
>
O.K. Here's a crazy idea...have you considered turning...
const struct whatever { int a; };
...into...
const struct whatever { const int a; };
In other words, pass down the const-ness to ActOnField()? Then the
qualifiers could be added to all the FieldDecls...
The only downside is distinguishing between "implicit/inherited"
qualifiers from qualifiers that are explicit in the source (but that
can obviously be fixed by saving the original type, if necessary).
This declaration-centric solution has some appeal...MemberExpr/Expr
wouldn't need to change.
snaroff
> (Note that we actually allow this for gcc compat, but the -pedantic
> warning that should show up doesn't show up.)
>
> Or the following:
> int a(volatile struct {int a;} * x) {
> x->a = 10;
> }
>
> Which will silently generate wrong code because it throws out the
> volatile qualifier.
> Pretty much anything that depends on qualifiers would require an
> independent fix for this issue, which seems like a bad idea.
>
> -Eli
_______________________________________________
cfe-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev