mirror of
https://github.com/verilator/verilator.git
synced 2025-04-11 23:46:55 +00:00
Tests: Make it mt-safe to call operators on guarded and local objects. (#3821)
This commit is contained in:
parent
982fa3d7bb
commit
cb413aa264
@ -318,8 +318,14 @@ class CallAnnotationsValidator:
|
|||||||
def find_object_ref(node):
|
def find_object_ref(node):
|
||||||
try:
|
try:
|
||||||
node = next(node.get_children())
|
node = next(node.get_children())
|
||||||
|
if node.kind == CursorKind.DECL_REF_EXPR:
|
||||||
|
# Operator on an argument or local object
|
||||||
|
return node
|
||||||
if node.kind != CursorKind.MEMBER_REF_EXPR:
|
if node.kind != CursorKind.MEMBER_REF_EXPR:
|
||||||
return None
|
return None
|
||||||
|
if node.referenced and node.referenced.kind == CursorKind.FIELD_DECL:
|
||||||
|
# Operator on a member object
|
||||||
|
return node
|
||||||
node = next(node.get_children())
|
node = next(node.get_children())
|
||||||
if node.kind == CursorKind.UNEXPOSED_EXPR:
|
if node.kind == CursorKind.UNEXPOSED_EXPR:
|
||||||
node = next(node.get_children())
|
node = next(node.get_children())
|
||||||
|
@ -104,6 +104,8 @@ struct GuardMe {
|
|||||||
void safe_if_guarded_or_local() {}
|
void safe_if_guarded_or_local() {}
|
||||||
|
|
||||||
operator int() const { return 4; }
|
operator int() const { return 4; }
|
||||||
|
|
||||||
|
GuardMe& operator+=(int) { return *this; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestClass {
|
class TestClass {
|
||||||
@ -250,20 +252,24 @@ public:
|
|||||||
void guarded_by_test_pass(GuardMe& guardme_arg) VL_MT_SAFE {
|
void guarded_by_test_pass(GuardMe& guardme_arg) VL_MT_SAFE {
|
||||||
guardme_arg.safe_if_guarded_or_local();
|
guardme_arg.safe_if_guarded_or_local();
|
||||||
int a = guardme_arg;
|
int a = guardme_arg;
|
||||||
|
guardme_arg += 4;
|
||||||
|
|
||||||
m_mtx.lock();
|
m_mtx.lock();
|
||||||
m_guardme.safe_if_guarded_or_local();
|
m_guardme.safe_if_guarded_or_local();
|
||||||
int b = m_guardme;
|
int b = m_guardme;
|
||||||
|
m_guardme += 4;
|
||||||
m_mtx.unlock();
|
m_mtx.unlock();
|
||||||
|
|
||||||
GuardMe guardme_local;
|
GuardMe guardme_local;
|
||||||
guardme_local.safe_if_guarded_or_local();
|
guardme_local.safe_if_guarded_or_local();
|
||||||
int c = guardme_local;
|
int c = guardme_local;
|
||||||
|
guardme_local += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
void guarded_by_test_fail() VL_MT_SAFE {
|
void guarded_by_test_fail() VL_MT_SAFE {
|
||||||
m_guardme_unguarded.safe_if_guarded_or_local();
|
m_guardme_unguarded.safe_if_guarded_or_local();
|
||||||
int a = m_guardme_unguarded;
|
int a = m_guardme_unguarded;
|
||||||
|
m_guardme_unguarded += 4;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user