From 5ff53b27dfd918a5d9943cd008de51edc8cbec2c Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Wed, 11 Jan 2012 08:19:46 +0000 Subject: Fixed VLA code generation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147933 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenFunction.cpp | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'lib/CodeGen/CodeGenFunction.cpp') diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index cde2de9819..5c21b0762b 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -935,20 +935,6 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { const Type *ty = type.getTypePtr(); switch (ty->getTypeClass()) { - default: - // Only sugared types (different from typeof_expr) can reach this point. - assert(!type.isCanonical() && "unhandled canonical type!"); - type = type.getSingleStepDesugaredType(getContext()); - break; - - case Type::TypeOfExpr: { - // This is the only sugared type requiring special treatment. - // Emit typeof expression and we are done. - Expr *E = cast(ty)->getUnderlyingExpr(); - EmitIgnoredExpr(E); - return; - } - #define TYPE(Class, Base) #define ABSTRACT_TYPE(Class, Base) #define NON_CANONICAL_TYPE(Class, Base) @@ -964,6 +950,8 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { case Type::ExtVector: case Type::Record: case Type::Enum: + case Type::Elaborated: + case Type::TemplateSpecialization: case Type::ObjCObject: case Type::ObjCInterface: case Type::ObjCObjectPointer: @@ -1018,6 +1006,26 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { type = cast(ty)->getResultType(); break; + case Type::Paren: + case Type::TypeOf: + case Type::UnaryTransform: + case Type::Attributed: + case Type::SubstTemplateTypeParm: + // Keep walking after single level desugaring. + type = type.getSingleStepDesugaredType(getContext()); + break; + + case Type::Typedef: + case Type::Decltype: + case Type::Auto: + // Stop walking: nothing to do. + return; + + case Type::TypeOfExpr: + // Stop walking: emit typeof expression. + EmitIgnoredExpr(cast(ty)->getUnderlyingExpr()); + return; + case Type::Atomic: type = cast(ty)->getValueType(); break; -- cgit v1.2.3-18-g5258