Skip to content

Commit 0298755

Browse files
committed
C++: Add a test.
1 parent 6e0f3df commit 0298755

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

cpp/ql/test/library-tests/controlflow/guards/Guards.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@
4242
| test.cpp:99:6:99:6 | f |
4343
| test.cpp:105:6:105:14 | ... != ... |
4444
| test.cpp:111:6:111:14 | ... != ... |
45+
| test.cpp:122:9:122:9 | b |
46+
| test.cpp:125:13:125:20 | ! ... |
47+
| test.cpp:125:14:125:17 | call to safe |

cpp/ql/test/library-tests/controlflow/guards/GuardsControl.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,7 @@
100100
| test.cpp:99:6:99:6 | f | true | 99 | 100 |
101101
| test.cpp:105:6:105:14 | ... != ... | true | 105 | 106 |
102102
| test.cpp:111:6:111:14 | ... != ... | true | 111 | 112 |
103+
| test.cpp:122:9:122:9 | b | true | 123 | 125 |
104+
| test.cpp:122:9:122:9 | b | true | 125 | 125 |
105+
| test.cpp:125:13:125:20 | ! ... | true | 125 | 125 |
106+
| test.cpp:125:14:125:17 | call to safe | false | 125 | 125 |

cpp/ql/test/library-tests/controlflow/guards/test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,17 @@ void int_float_comparison(int i) {
112112
use(i);
113113
}
114114
}
115+
116+
int source();
117+
bool safe(int);
118+
119+
void test(bool b)
120+
{
121+
int x;
122+
if (b)
123+
{
124+
x = source();
125+
if (!safe(x)) return;
126+
}
127+
use(x);
128+
}

0 commit comments

Comments
 (0)