[cfe-commits] r60615 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/AST/Expr.h include/clang/AST/Type.h lib/AST/ASTContext.cpp lib/AST/CFG.cpp lib/AST/Expr.cpp lib/AST/StmtIterator.cpp lib/AST/Type.cpp lib/AST/TypeSerialization.cpp

Eli Friedman eli.friedman at gmail.com
Wed Dec 10 15:10:13 PST 2008


On Wed, Dec 10, 2008 at 12:44 PM, Douglas Gregor <dgregor at apple.com> wrote:
>>> +/// getDependentSizedArrayType - Returns a non-unique reference to
>>> +/// the type for a dependently-sized array of the specified element
>>> +/// type. FIXME: We will need these to be uniqued, or at least
>>> +/// comparable, at some point.
>>>
>> Do VLAs have the same FIXME? Why do we need this?
>
> VLAs do have the same FIXME, although I don't think we actually need
> VLAs to be uniqued.

I'm pretty sure you're right: VLA types contain expressions that are
tied to the location of their declaration, so we don't want to unique
them.  In "int x=1;int a[x++];int b[x++];", for example, the sizes are
the same expression, but they're certainly not the same type.

> With dependently-sized array types, we need them
> to be unique so that we can determine that the types of the arrays
> match in the parameter types of the functions "f" below:
>
>        template<int I, int J> void f(int (&array)[I+J]);
>        template<int X, int Y> void f(int (&array)[X+Y]) { ... }
>
> If we don't realize that those canonical types match, we'll think that
> the definition is actually an overload rather than a redeclaration.
> Not good!

Ouch, seems like a pain to implement.

-Eli



More information about the cfe-commits mailing list