1 // RUN: %clang_analyze_cc1 %s -std=c++14 -analyzer-output=text -verify \
2 // RUN: -analyzer-checker=core,alpha.nondeterminism.PointerIteration
4 #include "Inputs/system-header-simulator-cxx.h"
9 void PointerIteration() {
11 std::set
<int> OrderedIntSet
= {a
, b
};
12 std::set
<int *> OrderedPtrSet
= {&a
, &b
};
13 std::unordered_set
<int> UnorderedIntSet
= {a
, b
};
14 std::unordered_set
<int *> UnorderedPtrSet
= {&a
, &b
};
16 for (auto i
: OrderedIntSet
) // no-warning
19 for (auto i
: OrderedPtrSet
) // no-warning
22 for (auto i
: UnorderedIntSet
) // no-warning
25 for (auto i
: UnorderedPtrSet
) // expected-warning {{Iteration of pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerIteration]
26 // expected-note@-1 {{Iteration of pointer-like elements can result in non-deterministic ordering}} [alpha.nondeterminism.PointerIteration]