Skip to content

Commit 9e2e0b5

Browse files
devajithvsRoot Persona
authored andcommitted
Fix SourceLocation test for C++20
1 parent 498015c commit 9e2e0b5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

test/Prompt/ValuePrinter/SourceLocation.C

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,30 @@
66
// LICENSE.TXT for details.
77

88
//------------------------------------------------------------------------------
9-
// RUN: cat %s | %cling | FileCheck %s
9+
// std::source_location is a C++20 feature.
10+
// RUN: cat %s | %cling -std=c++20 | FileCheck %s
1011

12+
.rawInput 1
1113
#include <iostream>
1214
#if __cplusplus >= 202002L
1315
#include <version>
1416
#endif
1517

16-
#ifndef __cpp_lib_source_location
17-
// Hack to prevent failure if __cpp_lib_source_location feature does not exist!
18-
std::cout << "(std::source_location) ";
19-
std::cout << "CHECK_SRCLOC:42:std::source_location getsrcloc()\n";
20-
#else
18+
#ifdef __cpp_lib_source_location
2119
#include <source_location>
2220
std::source_location getsrcloc() {
2321
#line 42 "CHECK_SRCLOC"
2422
return std::source_location::current();
2523
}
26-
getsrcloc()
24+
#else
25+
// Hack to prevent failure if __cpp_lib_source_location feature does not exist!
26+
void getsrcloc() {
27+
std::cout << "(std::source_location) ";
28+
std::cout << "CHECK_SRCLOC:42:std::source_location getsrcloc()\n";
29+
}
2730
#endif
31+
.rawInput 0
32+
33+
getsrcloc()
2834
// CHECK: (std::source_location)
2935
// CHECK: CHECK_SRCLOC:42:std::source_location getsrcloc()

0 commit comments

Comments
 (0)