r186452 - Fix crash on complex constant zero.
Eli Friedman
eli.friedman at gmail.com
Tue Jul 16 13:19:04 PDT 2013
Author: efriedma
Date: Tue Jul 16 15:19:04 2013
New Revision: 186452
URL: http://llvm.org/viewvc/llvm-project?rev=186452&view=rev
Log:
Fix crash on complex constant zero.
Fixes <rdar://problem/14442543>.
Modified:
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/test/CodeGen/complex.c
Modified: cfe/trunk/lib/CodeGen/CGExprComplex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprComplex.cpp?rev=186452&r1=186451&r2=186452&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Tue Jul 16 15:19:04 2013
@@ -114,9 +114,9 @@ public:
if (result.isReference())
return EmitLoadOfLValue(result.getReferenceLValue(CGF, E));
- llvm::ConstantStruct *pair =
- cast<llvm::ConstantStruct>(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);
}
Modified: cfe/trunk/test/CodeGen/complex.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/complex.c?rev=186452&r1=186451&r2=186452&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/complex.c (original)
+++ cfe/trunk/test/CodeGen/complex.c Tue Jul 16 15:19:04 2013
@@ -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; }
More information about the cfe-commits
mailing list