[cfe-commits] Unique'ing VariableArrayType
Argiris Kirtzidis
akyrtzi at gmail.com
Wed Oct 8 16:20:16 PDT 2008
After the subtle bug that was uncovered here:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20081006/008095.html
I think that VariableArrayTypes should be unique'd based on the
expression that represents the size.
The comments of over VariableArrayType class mention:
> /// Note: VariableArrayType's aren't uniqued (since the expressions
> aren't) and
> /// should not be: two lexically equivalent variable array types could
> mean
> /// different things, for example, these variables do not have the
> same type
> /// dynamically:
> ///
> /// void foo(int x) {
> /// int Y[x];
> /// ++x;
> /// int Z[x];
> /// }
But those two '[x]' expressions are different DeclRefExpr objects.
Not unique'ing the VariableArrayTypes doesn't seem to have any benefit,
since it's a bug to create two VariableArrayTypes with the same Expr*
(they will both try to destroy it).
And in general it's unintuitive to have Sema::GetTypeForDeclarator
create different Type* objects each time it gets called with the exact
same declarator.
Any thoughts ?
-Argiris
More information about the cfe-commits
mailing list