From 64f23918992bc99d8a0b4418f9787bc78cfd2975 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 16 Jul 2013 20:19:04 +0000 Subject: [PATCH] Fix crash on complex constant zero. Fixes . llvm-svn: 186452 --- clang/lib/CodeGen/CGExprComplex.cpp | 6 +++--- clang/test/CodeGen/complex.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index e4b2f3b3fb42..796c55a4bdbc 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -114,9 +114,9 @@ public: if (result.isReference()) return EmitLoadOfLValue(result.getReferenceLValue(CGF, E)); - llvm::ConstantStruct *pair = - cast(result.getValue()); - return ComplexPairTy(pair->getOperand(0), pair->getOperand(1)); + llvm::Constant *pair = result.getValue(); + return ComplexPairTy(pair->getAggregateElement(0U), + pair->getAggregateElement(1U)); } return EmitLoadOfLValue(E); } diff --git a/clang/test/CodeGen/complex.c b/clang/test/CodeGen/complex.c index e99a7152813a..206db253caa4 100644 --- a/clang/test/CodeGen/complex.c +++ b/clang/test/CodeGen/complex.c @@ -95,3 +95,6 @@ double t7(double _Complex c) { void t8() { __complex__ int *x = &(__complex__ int){1}; } + +const _Complex double test9const = 0; +_Complex double test9func() { return test9const; }