Debian Codegraph @

clang/test/SemaCXX/range-for-lifetime-cxx23.cpp

raw
1 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify %s
2
3 using size_t = decltype(sizeof(void *));
4
5 namespace std {
6 template <typename T> struct vector {
7 T &operator[](size_t I);
8 };
9
10 struct string {
11 const char *begin();
12 const char *end();
13 };
14
15 } // namespace std
16
17 std::vector<std::string> getData();
18
19 void foo() {
20 // Verifies we don't trigger a diagnostic from -Wdangling-gsl
21 // when iterating over a temporary in C++23.
22 for (auto c : getData()[0]) {
23 (void)c;
24 }
25 }
26
27 // expected-no-diagnostics