Skip to content

Commit

Permalink
Add TEST_IF_AIX to fix warning C5101: use of preprocessor directive i…
Browse files Browse the repository at this point in the history
…n function-like macro argument list is undefined behavior
  • Loading branch information
StephanTLavavej committed Nov 26, 2023
1 parent 9ba74c2 commit b037e24
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,8 @@ static void test_read_only() {
TEST_VALIDATE_EXCEPTION(
std::system_error,
[&]([[maybe_unused]] const std::system_error& e) {
#ifdef _AIX
[[maybe_unused]] std::string_view what{"failed to write formatted output: Broken pipe"};
#else
[[maybe_unused]] std::string_view what{"failed to write formatted output: Operation not permitted"};
#endif
[[maybe_unused]] std::string_view what{
"failed to write formatted output: " TEST_IF_AIX("Broken pipe", "Operation not permitted")};
TEST_LIBCPP_REQUIRE(
e.what() == what,
TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,8 @@ static void test_read_only() {
TEST_VALIDATE_EXCEPTION(
std::system_error,
[&]([[maybe_unused]] const std::system_error& e) {
#ifdef _AIX
[[maybe_unused]] std::string_view what{"failed to write formatted output: Broken pipe"};
#else
[[maybe_unused]] std::string_view what{"failed to write formatted output: Operation not permitted"};
#endif
[[maybe_unused]] std::string_view what{
"failed to write formatted output: " TEST_IF_AIX("Broken pipe", "Operation not permitted")};
TEST_LIBCPP_REQUIRE(
e.what() == what,
TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,8 @@ static void test_read_only() {
TEST_VALIDATE_EXCEPTION(
std::system_error,
[&]([[maybe_unused]] const std::system_error& e) {
#ifdef _AIX
[[maybe_unused]] std::string_view what{"failed to write formatted output: Broken pipe"};
#else
[[maybe_unused]] std::string_view what{"failed to write formatted output: Operation not permitted"};
#endif
[[maybe_unused]] std::string_view what{
"failed to write formatted output: " TEST_IF_AIX("Broken pipe", "Operation not permitted")};
TEST_LIBCPP_REQUIRE(
e.what() == what,
TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,8 @@ static void test_read_only() {
TEST_VALIDATE_EXCEPTION(
std::system_error,
[&]([[maybe_unused]] const std::system_error& e) {
#ifdef _AIX
[[maybe_unused]] std::string_view what{"failed to write formatted output: Broken pipe"};
#else
[[maybe_unused]] std::string_view what{"failed to write formatted output: Operation not permitted"};
#endif
[[maybe_unused]] std::string_view what{
"failed to write formatted output: " TEST_IF_AIX("Broken pipe", "Operation not permitted")};
TEST_LIBCPP_REQUIRE(
e.what() == what,
TEST_WRITE_CONCATENATED("\nExpected exception ", what, "\nActual exception ", e.what(), '\n'));
Expand Down
6 changes: 6 additions & 0 deletions libcxx/test/support/test_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,10 @@ inline void DoNotOptimize(Tp const& value) {
# define TEST_WORKAROUND_BUG_109234844_WEAK /* nothing */
#endif

#ifdef _AIX
# define TEST_IF_AIX(arg_true, arg_false) arg_true
#else
# define TEST_IF_AIX(arg_true, arg_false) arg_false
#endif

#endif // SUPPORT_TEST_MACROS_HPP

0 comments on commit b037e24

Please sign in to comment.