Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions compiler-rt/test/rtsan/coroutine.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN: %clangxx -std=c++20 -fsanitize=realtime %s -o %t
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only valid in C++20, what should I do to ensure it doesn't affect systems without c++20? This test should be a no-op in that case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a system without C++20? This is a test of clang trunk, which supports C++20?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running through this test on one of my older ubuntu machines, I get this error:

/test_radsan/llvm-project/compiler-rt/test/rtsan/coroutine.cpp:7:10: fatal error: 'coroutine' file not found
    7 | #include <coroutine>                                                                                                                                        |          ^~~~~~~~~~~

That led me to believe that I needed to do something special here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, hmm, yes that makes sense, you are right. That means the lib(std)c++ it uses is too old.

// RUN: not %run %t 2>&1 | FileCheck %s
// UNSUPPORTED: ios

// Intent: Coroutines allocate memory and are not allowed in a [[clang::nonblocking]] function.

#include <coroutine>

struct SimpleCoroutine {
struct promise_type {
SimpleCoroutine get_return_object() { return SimpleCoroutine{}; }
std::suspend_never initial_suspend() { return {}; }
std::suspend_never final_suspend() noexcept { return {}; }
void unhandled_exception() {}
void return_void() {}
};
};

SimpleCoroutine example_coroutine() { co_return; }

void calls_a_coroutine() [[clang::nonblocking]] { example_coroutine(); }

int main() {
calls_a_coroutine();
return 0;
}

// CHECK: ==ERROR: RealtimeSanitizer

// Somewhere in the stack this should be mentioned
// CHECK: calls_a_coroutine
Loading