Debian Codegraph @

gcc/testsuite/g++.dg/tree-ssa/empty-loop.C

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ffinite-loops -Wno-unused-result" } */
3 /* { dg-additional-options "-fdump-tree-cddce2 -fdump-tree-cddce3" } */
4 /* { dg-skip-if "requires hosted libstdc++ for string" { ! hostedlib } } */
5
6 #include <string>
7 #include <vector>
8 #include <list>
9 #include <set>
10 #include <map>
11
12 using namespace std;
13
14 int foo (vector<string> &v, list<string> &l, set<string> &s, map<int, string> &m)
15 {
16 for (vector<string>::iterator it = v.begin (); it != v.end (); ++it)
17 it->length();
18
19 for (list<string>::iterator it = l.begin (); it != l.end (); ++it)
20 it->length();
21
22 for (map<int, string>::iterator it = m.begin (); it != m.end (); ++it)
23 it->first + it->second.length();
24
25 for (set<string>::iterator it0 = s.begin (); it0 != s.end(); ++it0)
26 for (vector<string>::reverse_iterator it1 = v.rbegin(); it1 != v.rend(); ++it1)
27 {
28 it0->length();
29 it1->length();
30 }
31
32 return 0;
33 }
34 /* Adding __builtin_unreachable to std::string::size() prevents cddce2 from
35 eliminating the loop early, see PR117764. */
36 /* { dg-final { scan-tree-dump-not "if" "cddce2" { xfail *-*-* } } } */
37 /* { dg-final { scan-tree-dump-not "if" "cddce3"} } */
38