| 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 %t/a.cppm -o %t/a.pcm |
| 6 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fprebuilt-module-path=%t -emit-module-interface -o %t/b.pcm -verify |
| 7 |
// |
| 8 |
// Testing the behavior of `-fskip-odr-check-in-gmf` |
| 9 |
// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf -emit-module-interface %t/a.cppm -o \ |
| 10 |
// RUN: %t/a.pcm |
| 11 |
// RUN: %clang_cc1 -std=c++20 -fskip-odr-check-in-gmf %t/b.cppm -fprebuilt-module-path=%t \ |
| 12 |
// RUN: -emit-module-interface -DSKIP_ODR_CHECK_IN_GMF -o %t/b.pcm -verify |
| 13 |
|
| 14 |
// RUN: %clang_cc1 -std=c++20 -emit-reduced-module-interface %t/a.cppm -o %t/a.pcm |
| 15 |
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -fprebuilt-module-path=%t -emit-reduced-module-interface \ |
| 16 |
// RUN: -o %t/b.pcm -verify -DREDUCED |
| 17 |
|
| 18 |
//--- foo.h |
| 19 |
|
| 20 |
namespace std |
| 21 |
{ |
| 22 |
template<class _Dom1> |
| 23 |
void operator &&(_Dom1 __v, _Dom1 __w) |
| 24 |
{ |
| 25 |
return; |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
//--- bar.h |
| 30 |
namespace std |
| 31 |
{ |
| 32 |
template<typename... _Types> |
| 33 |
struct _Traits |
| 34 |
{ |
| 35 |
static constexpr bool _S_copy_ctor = |
| 36 |
(__is_trivial(_Types) && ...); |
| 37 |
}; |
| 38 |
|
| 39 |
template<typename... _Types> |
| 40 |
struct variant |
| 41 |
{ |
| 42 |
void |
| 43 |
swap(variant& __rhs) |
| 44 |
noexcept((__is_trivial(_Types) && ...)) |
| 45 |
{ |
| 46 |
} |
| 47 |
}; |
| 48 |
} |
| 49 |
|
| 50 |
//--- a.cppm |
| 51 |
module; |
| 52 |
// The operator&& defined in 'foo.h' will pollute the |
| 53 |
// expression '__is_trivial(_Types) && ...' in bar.h |
| 54 |
#include "foo.h" |
| 55 |
#include "bar.h" |
| 56 |
export module a; |
| 57 |
export namespace std { |
| 58 |
using std::variant; |
| 59 |
using std::_Traits; |
| 60 |
using std::operator&&; |
| 61 |
} |
| 62 |
|
| 63 |
//--- b.cppm |
| 64 |
module; |
| 65 |
#include "bar.h" |
| 66 |
export module b; |
| 67 |
import a; |
| 68 |
export namespace std { |
| 69 |
using std::variant; |
| 70 |
using std::_Traits; |
| 71 |
using std::operator&&; |
| 72 |
} |
| 73 |
|
| 74 |
#ifdef SKIP_ODR_CHECK_IN_GMF |
| 75 |
// expected-no-diagnostics |
| 76 |
#else |
| 77 |
// expected-error@* {{has different definitions in different modules; first difference is defined here found data member '_S_copy_ctor' with an initializer}} |
| 78 |
// expected-note@* {{but in 'a.<global>' found data member '_S_copy_ctor' with a different initializer}} |
| 79 |
#endif |