
This patch does a few things: * Fix aggregate initialization. When an aggregate has an initializer that is immediate-escalating, the context in which it is used automatically becomes an immediate function. The wording does that by rpretending an aggregate initialization is itself an invocation which is not really how clang works, so my previous attempt was... wrong. * Fix initialization of defaulted constructors with immediate escalating default member initializers. The wording was silent about that case and I did not handled it fully https://cplusplus.github.io/CWG/issues/2760.html * Fix diagnostics In some cases clang would produce additional and unhelpful diagnostics by listing the invalid references to consteval function that appear in immediate escalating functions Fixes https://github.com/llvm/llvm-project/issues/63742 Reviewed By: aaron.ballman, #clang-language-wg, Fznamznon Differential Revision: https://reviews.llvm.org/D155175
22 lines
421 B
C++
22 lines
421 B
C++
// RUN: %clang_cc1 -emit-llvm %s -std=c++20 -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
|
|
|
|
namespace GH63742 {
|
|
|
|
void side_effect();
|
|
consteval int f(int x) {
|
|
if (!__builtin_is_constant_evaluated()) side_effect();
|
|
return x;
|
|
}
|
|
struct SS {
|
|
int x = f(42);
|
|
SS();
|
|
};
|
|
SS::SS(){}
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: @_ZN7GH637422SSC2Ev
|
|
// CHECK-NOT: call
|
|
// CHECK: store i32 42, ptr {{.*}}
|
|
// CHECK: ret void
|