// RUN: rm -fR %t // RUN: split-file %s %t // RUN: cd %t // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header -Werror=uninitialized folly-conv.h // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header -Werror=uninitialized thrift_cpp2_base.h // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header -Werror=uninitialized -fmodule-file=folly-conv.pcm -fmodule-file=thrift_cpp2_base.pcm logger_base.h //--- Conv.h #pragma once template _Up __declval(int); template auto declval() noexcept -> decltype(__declval<_Tp>(0)); namespace folly { template struct Expected { template auto thenOrThrow() -> decltype(declval()) { return 1; } }; struct ExpectedHelper { template static constexpr Expected return_(T) { return Expected(); } template static auto then_(This&&, Fn&&) -> decltype(T::template return_((declval()(true), 0))) { return Expected(); } }; template inline Expected tryTo() { Tgt result = 0; // In build with asserts: // clang/lib/Sema/SemaTemplateInstantiate.cpp: llvm::PointerUnion *clang::LocalInstantiationScope::findInstantiationOf(const Decl *): Assertion `isa(D) && "declaration not instantiated in this scope"' failed. // In release build compilation error on the line below inside lambda: // error: variable 'result' is uninitialized when used here [-Werror,-Wuninitialized] ExpectedHelper::then_(Expected(), [&](bool) { return result; }); return {}; } } // namespace folly inline void bar() { folly::tryTo(); } // expected-no-diagnostics //--- folly-conv.h #pragma once #include "Conv.h" // expected-no-diagnostics //--- thrift_cpp2_base.h #pragma once #include "Conv.h" // expected-no-diagnostics //--- logger_base.h #pragma once import "folly-conv.h"; import "thrift_cpp2_base.h"; inline void foo() { folly::tryTo(); } // expected-no-diagnostics