Make sure to access APValue's data via a char array (rather than
through an array of void*), so that we don't run afoul of the
strict-aliasing rules in C++ 3.10p15. Unfortunately, GCC 4.4 still
complains about this code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@81251 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/APValue.cpp b/lib/AST/APValue.cpp
index 4df7671..489dac7 100644
--- a/lib/AST/APValue.cpp
+++ b/lib/AST/APValue.cpp
@@ -37,7 +37,7 @@
else if (isFloat())
setFloat(RHS.getFloat());
else if (isVector())
- setVector(((Vec*)(void*)RHS.Data)->Elts, RHS.getVectorLength());
+ setVector(((Vec*)(char*)RHS.Data)->Elts, RHS.getVectorLength());
else if (isComplexInt())
setComplexInt(RHS.getComplexIntReal(), RHS.getComplexIntImag());
else if (isComplexFloat())
@@ -49,17 +49,17 @@
void APValue::MakeUninit() {
if (Kind == Int)
- ((APSInt*)(void*)Data)->~APSInt();
+ ((APSInt*)(char*)Data)->~APSInt();
else if (Kind == Float)
- ((APFloat*)(void*)Data)->~APFloat();
+ ((APFloat*)(char*)Data)->~APFloat();
else if (Kind == Vector)
- ((Vec*)(void*)Data)->~Vec();
+ ((Vec*)(char*)Data)->~Vec();
else if (Kind == ComplexInt)
- ((ComplexAPSInt*)(void*)Data)->~ComplexAPSInt();
+ ((ComplexAPSInt*)(char*)Data)->~ComplexAPSInt();
else if (Kind == ComplexFloat)
- ((ComplexAPFloat*)(void*)Data)->~ComplexAPFloat();
+ ((ComplexAPFloat*)(char*)Data)->~ComplexAPFloat();
else if (Kind == LValue) {
- ((LV*)(void*)Data)->~LV();
+ ((LV*)(char*)Data)->~LV();
}
Kind = Uninitialized;
}