diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-05-23 16:10:32 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-05-23 16:10:32 +0000 |
commit | 715e9c8a39437347e838aa108df443fe1086d359 (patch) | |
tree | a5236afdb0b40417eb94c714a3e42b376b400465 | |
parent | fa037bd3f79d3c70197a3224bb1b29c6c4af0098 (diff) |
Even though we don't unique VLA types, we still need to build a
canonical type where the element type is canonical. Fixes PR7206.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104461 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ASTContext.cpp | 12 | ||||
-rw-r--r-- | test/SemaCXX/c99-variable-length-array.cpp | 10 |
2 files changed, 20 insertions, 2 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 720a88c6b6..801a1f6391 100644 --- a/lib/AST/ASTContext.cpp +++ b/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); diff --git a/test/SemaCXX/c99-variable-length-array.cpp b/test/SemaCXX/c99-variable-length-array.cpp index a792951252..14dc0ae2e8 100644 --- a/test/SemaCXX/c99-variable-length-array.cpp +++ b/test/SemaCXX/c99-variable-length-array.cpp @@ -78,3 +78,13 @@ void local_classes(int N) { int array[N]; // expected-error{{fields must have a constant size: 'variable length array in structure' extension will never be supported}} }; } + +namespace PR7206 { + void f(int x) { + struct edge_info { + float left; + float right; + }; + struct edge_info edgeInfo[x]; + } +} |