| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
|
| 5 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -o %t/format.pcm %t/format.cppm |
| 6 |
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -o %t/includes_in_gmf.pcm %t/includes_in_gmf.cppm |
| 7 |
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/test.cpp -fsyntax-only -verify |
| 8 |
|
| 9 |
//--- format.h |
| 10 |
#pragma once |
| 11 |
|
| 12 |
namespace test { |
| 13 |
|
| 14 |
template <class _Tp> |
| 15 |
struct type_identity { |
| 16 |
typedef _Tp type; |
| 17 |
}; |
| 18 |
|
| 19 |
template <class> struct formatter; |
| 20 |
template <> struct formatter<char> {}; |
| 21 |
|
| 22 |
template <class T, class> |
| 23 |
struct basic_format_string { |
| 24 |
static inline const int __handles_ = [] { |
| 25 |
static_assert(__is_same(T, char)); |
| 26 |
return 0; |
| 27 |
}(); |
| 28 |
|
| 29 |
basic_format_string(const T*) { |
| 30 |
static_assert(__is_same(T, char)); |
| 31 |
(void)__handles_; |
| 32 |
} |
| 33 |
}; |
| 34 |
|
| 35 |
template <class T> |
| 36 |
void format(basic_format_string<char, typename type_identity<T>::type>, T) {} |
| 37 |
|
| 38 |
template <class T> |
| 39 |
void format(basic_format_string<wchar_t, typename type_identity<T>::type>, T) = delete; |
| 40 |
} |
| 41 |
|
| 42 |
//--- format.cppm |
| 43 |
module; |
| 44 |
#include "format.h" |
| 45 |
export module format; |
| 46 |
|
| 47 |
export namespace test { |
| 48 |
using test::format; |
| 49 |
} |
| 50 |
|
| 51 |
void something() { |
| 52 |
test::format("", 0); |
| 53 |
} |
| 54 |
|
| 55 |
//--- includes_in_gmf.cppm |
| 56 |
module; |
| 57 |
#include "format.h" |
| 58 |
export module includes_in_gmf; |
| 59 |
|
| 60 |
//--- test.cpp |
| 61 |
// expected-no-diagnostics |
| 62 |
|
| 63 |
#include "format.h" // Uncomment this to get the good version. |
| 64 |
import format; |
| 65 |
import includes_in_gmf; |
| 66 |
|
| 67 |
void f() { |
| 68 |
test::format("", 0); |
| 69 |
test::format("", 'r'); |
| 70 |
} |