[clang] [Clang] Use correct evaluation contexts when instantiating a var without initializer (PR #140699)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Tue May 20 07:25:16 PDT 2025


================
@@ -18,6 +18,16 @@ int init_arr();
 template<typename T> template<typename U> template<typename V> int Outer<T>::Inner<U>::arr[sizeof(T) + sizeof(U) + sizeof(V)] = { init_arr() };
 int *p = Outer<char[100]>::Inner<char[20]>::arr<char[3]>;
 
+//CHECK: @_ZN8GH1406221gIiEE = linkonce_odr constant %"struct.GH140622::S" zeroinitializer
+namespace GH140622 {
+template <typename> struct S {};
+template <typename T> constexpr S<T> g;
+void test() {
+    constexpr auto x = 42;
----------------
shafik wrote:

As I pointed out here: https://github.com/llvm/llvm-project/issues/140622#issuecomment-2892633775

this also happens when the local is *const*, so it is worth testing that case and the non const/constexpr case.

https://github.com/llvm/llvm-project/pull/140699


More information about the cfe-commits mailing list