Skip to content

Commit bd07e7b

Browse files
committed
Add a unit test that reproduces the assertion failure during bootstrap
build on OS X with XCode.
1 parent 3f88306 commit bd07e7b

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

clang/test/Modules/pr129982.cpp

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// If this test fails, it should be investigated under Debug builds.
2+
// Before the PR, this test was violating an assertion.
3+
4+
// RUN: rm -rf %t
5+
// RUN: mkdir -p %t
6+
// RUN: split-file %s %t
7+
8+
// RUN: %clang_cc1 -std=c++20 -emit-obj -fmodules \
9+
// RUN: -fmodule-map-file=%t/module.modulemap \
10+
// RUN: -fmodules-cache-path=%t %t/a.cpp
11+
12+
//--- module.modulemap
13+
module ebo {
14+
header "ebo.h"
15+
}
16+
17+
module fwd {
18+
header "fwd.h"
19+
}
20+
21+
module s {
22+
header "s.h"
23+
export *
24+
}
25+
26+
module mod {
27+
header "a.h"
28+
header "b.h"
29+
}
30+
31+
//--- ebo.h
32+
#pragma once
33+
34+
namespace N { inline namespace __1 {
35+
36+
template <typename T>
37+
struct EBO : T {
38+
EBO() = default;
39+
};
40+
41+
}}
42+
43+
//--- fwd.h
44+
#pragma once
45+
46+
namespace N { inline namespace __1 {
47+
48+
template <typename T>
49+
struct Empty;
50+
51+
template <typename T>
52+
struct BS;
53+
54+
using S = BS<Empty<char>>;
55+
56+
}}
57+
58+
//--- s.h
59+
#pragma once
60+
61+
#include "fwd.h"
62+
#include "ebo.h"
63+
64+
namespace N { inline namespace __1 {
65+
66+
template <typename T>
67+
struct Empty {};
68+
69+
template <typename T>
70+
struct BS {
71+
EBO<T> _;
72+
void f();
73+
};
74+
75+
extern template void BS<Empty<char>>::f();
76+
77+
}}
78+
79+
//--- b.h
80+
#pragma once
81+
82+
#include "s.h"
83+
84+
struct B {
85+
void f() {
86+
N::S{}.f();
87+
}
88+
};
89+
90+
//--- a.h
91+
#pragma once
92+
93+
#include "s.h"
94+
95+
struct A {
96+
void f(int) {}
97+
void f(const N::S &) {}
98+
99+
void g();
100+
};
101+
102+
//--- a.cpp
103+
#include "a.h"
104+
105+
void A::g() { f(0); }
106+
107+
// expected-no-diagnostics

0 commit comments

Comments
 (0)