llvm-project/clang/test/CodeGenCXX/constexpr-late-instantiation.cpp
serge-sans-paille da6a14b91a [clang] Enforce instantiation of constexpr template functions during non-constexpr evaluation
Otherwise these functions are not instantiated and we end up with an undefined
symbol.

Fix #55560

Differential Revision: https://reviews.llvm.org/D128119
2022-07-10 08:40:03 +02:00

18 lines
378 B
C++

// Make sure foo is instantiated and we don't get a link error
// RUN: %clang_cc1 -S -emit-llvm -triple %itanium_abi_triple %s -o- | FileCheck %s
template <typename T>
constexpr T foo(T a);
// CHECK-LABEL: define {{.*}} @main
int main() {
// CHECK: call {{.*}} @_Z3fooIiET_S0_
int k = foo<int>(5);
}
// CHECK: }
template <typename T>
constexpr T foo(T a) {
return a;
}