Author: Chuanqi Xu Date: 2025-12-19T16:47:19+08:00 New Revision: 8994d399fa22440164532d32ef3b18944ea58531
URL: https://github.com/llvm/llvm-project/commit/8994d399fa22440164532d32ef3b18944ea58531 DIFF: https://github.com/llvm/llvm-project/commit/8994d399fa22440164532d32ef3b18944ea58531.diff LOG: [NFC] [C++20] [Modules] Add a test for issue 149404 Close https://github.com/llvm/llvm-project/issues/149404 and add its reproducer Added: clang/test/Modules/pr149404.cppm Modified: Removed: ################################################################################ diff --git a/clang/test/Modules/pr149404.cppm b/clang/test/Modules/pr149404.cppm new file mode 100644 index 0000000000000..e0b53670fc78a --- /dev/null +++ b/clang/test/Modules/pr149404.cppm @@ -0,0 +1,70 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: split-file %s %t + +// RUN: %clang_cc1 -std=c++20 -emit-module-interface -o %t/format.pcm %t/format.cppm +// RUN: %clang_cc1 -std=c++20 -emit-module-interface -o %t/includes_in_gmf.pcm %t/includes_in_gmf.cppm +// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/test.cpp -fsyntax-only -verify + +//--- format.h +#pragma once + +namespace test { + +template <class _Tp> +struct type_identity { + typedef _Tp type; +}; + +template <class> struct formatter; +template <> struct formatter<char> {}; + +template <class T, class> +struct basic_format_string { + static inline const int __handles_ = [] { + static_assert(__is_same(T, char)); + return 0; + }(); + + basic_format_string(const T*) { + static_assert(__is_same(T, char)); + (void)__handles_; + } +}; + +template <class T> +void format(basic_format_string<char, typename type_identity<T>::type>, T) {} + +template <class T> +void format(basic_format_string<wchar_t, typename type_identity<T>::type>, T) = delete; +} + +//--- format.cppm +module; +#include "format.h" +export module format; + +export namespace test { + using test::format; +} + +void something() { + test::format("", 0); +} + +//--- includes_in_gmf.cppm +module; +#include "format.h" +export module includes_in_gmf; + +//--- test.cpp +// expected-no-diagnostics + +#include "format.h" // Uncomment this to get the good version. +import format; +import includes_in_gmf; + +void f() { + test::format("", 0); + test::format("", 'r'); +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
