driver mode and emit an error which suggests using ``/TC`` or ``/TP``
``clang-cl`` options instead. This fixes
`Issue 59307 <https://github.com/llvm/llvm-project/issues/59307>`_.
+- Fix crash when evaluating consteval constructor of derived class whose base
+ has more than one field. This fixes
+ `Issue 60166 <https://github.com/llvm/llvm-project/issues/60166>`_.
Improvements to Clang's diagnostics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
EnsureDest(E->getType());
if (llvm::Value *Result = ConstantEmitter(CGF).tryEmitConstantExpr(E)) {
- CGF.EmitAggregateStore(Result, Dest.getAddress(),
+ Address StoreDest = Dest.getAddress();
+ // The emitted value is guaranteed to have the same size as the
+ // destination but can have a different type. Just do a bitcast in this
+ // case to avoid incorrect GEPs.
+ if (Result->getType() != StoreDest.getType())
+ StoreDest =
+ CGF.Builder.CreateElementBitCast(StoreDest, Result->getType());
+ CGF.EmitAggregateStore(Result, StoreDest,
E->getType().isVolatileQualified());
return;
}
}
} // namespace Issue55065
+namespace GH60166 {
+
+struct Base {
+ void* one = nullptr;
+ void* two = nullptr;
+};
+
+struct Derived : Base {
+ void* three = nullptr;
+ consteval Derived() = default;
+};
+
+void method() {
+ // CHECK: %agg.tmp.ensured = alloca %"struct.GH60166::Derived"
+ // CHECK: %0 = getelementptr inbounds { ptr, ptr, ptr }, ptr %agg.tmp.ensured, i32 0, i32 0
+ // CHECK: store ptr null, ptr %0, align 8
+ // CHECK: %1 = getelementptr inbounds { ptr, ptr, ptr }, ptr %agg.tmp.ensured, i32 0, i32 1
+ // CHECK: store ptr null, ptr %1, align 8
+ // CHECK: %2 = getelementptr inbounds { ptr, ptr, ptr }, ptr %agg.tmp.ensured, i32 0, i32 2
+ // CHECK: store ptr null, ptr %2, align 8
+ (void)Derived();
+}
+
+} // namespace GH60166