From 5e8c8c0e12ac15d0c07e84eccdcc7c58acb9fdad Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sun, 23 May 2010 16:10:32 +0000 Subject: Even though we don't unique VLA types, we still need to build a canonical type where the element type is canonical. Fixes PR7206. llvm-svn: 104461 --- clang/lib/AST/ASTContext.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'clang/lib/AST') diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 720a88c6b67..801a1f63917 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1356,9 +1356,17 @@ QualType ASTContext::getVariableArrayType(QualType EltTy, SourceRange Brackets) { // Since we don't unique expressions, it isn't possible to unique VLA's // that have an expression provided for their size. - + QualType CanonType; + + if (!EltTy.isCanonical()) { + if (NumElts) + NumElts->Retain(); + CanonType = getVariableArrayType(getCanonicalType(EltTy), NumElts, ASM, + EltTypeQuals, Brackets); + } + VariableArrayType *New = new(*this, TypeAlignment) - VariableArrayType(EltTy, QualType(), NumElts, ASM, EltTypeQuals, Brackets); + VariableArrayType(EltTy, CanonType, NumElts, ASM, EltTypeQuals, Brackets); VariableArrayTypes.push_back(New); Types.push_back(New); -- cgit v1.2.3