Skip to content

Commit 97c685c

Browse files
committed
Test cases for virtual inheritance
1 parent 6dc5002 commit 97c685c

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

clang/test/Analysis/block-in-critical-section-inheritance.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,26 @@ void two_custom_mutex_bases_casts_tn(MyMutex &m) {
128128
sleep(10);
129129
}
130130

131+
struct MutexVirtBase1 : virtual std::mutex {
132+
void lock1() { lock(); }
133+
void unlock1() { unlock(); }
134+
};
135+
136+
struct MutexVirtBase2 : virtual std::mutex {
137+
void lock2() { lock(); }
138+
void unlock2() { unlock(); }
139+
};
140+
141+
struct CombinedVirtMutex : MutexVirtBase1, MutexVirtBase2 {};
142+
143+
void virt_inherited_mutexes_same_base_tn1(CombinedVirtMutex &cvt) {
144+
cvt.lock1();
145+
cvt.unlock1();
146+
sleep(10);
147+
}
148+
149+
void virt_inherited_mutexes_different_bases_tn(CombinedVirtMutex &cvt) {
150+
cvt.lock1();
151+
cvt.unlock2(); // Despite a different name, unlock2 acts on the same mutex as lock1
152+
sleep(10);
153+
}

0 commit comments

Comments
 (0)