Skip to content

Commit b39fbb4

Browse files
committed
C++: Add a failing test with a default argument constructor.
1 parent 7e3ef2d commit b39fbb4

4 files changed

Lines changed: 17 additions & 0 deletions

File tree

cpp/ql/test/library-tests/dataflow/external-models/flow.ext.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extensions:
4949
- ["", "Container", True, "emplace", "", "", "Argument[forward].Parameter[-1]", "Argument[-1].Element", "value", "manual"]
5050
- ["", "Container", True, "get", "", "", "Argument[-1].Element", "ReturnValue[*]", "value", "manual"]
5151
- ["", "Element", True, "Element", "", "", "Argument[0]", "Argument[-1].Field[Element::x]", "value", "manual"]
52+
- ["", "ElementWithDefaultArgument", True, "ElementWithDefaultArgument", "", "", "Argument[0]", "Argument[-1].Field[ElementWithDefaultArgument::x]", "value", "manual"]
5253
- addsTo:
5354
pack: codeql/cpp-all
5455
extensible: forwardsModel

cpp/ql/test/library-tests/dataflow/external-models/sinks.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@
4848
| test.cpp:374:15:374:15 | s | test-sink |
4949
| test.cpp:375:15:375:16 | ul | test-sink |
5050
| test.cpp:398:13:398:13 | x | test-sink |
51+
| test.cpp:412:13:412:13 | x | test-sink |

cpp/ql/test/library-tests/dataflow/external-models/sources.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
| test.cpp:361:15:361:23 | call to ymlSource | local |
2323
| test.cpp:370:24:370:32 | call to ymlSource | local |
2424
| test.cpp:394:11:394:19 | call to ymlSource | local |
25+
| test.cpp:408:11:408:19 | call to ymlSource | local |
2526
| windows.cpp:22:15:22:29 | call to GetCommandLineA | local |
2627
| windows.cpp:34:17:34:38 | call to GetEnvironmentStringsA | local |
2728
| windows.cpp:39:36:39:38 | GetEnvironmentVariableA output argument | local |

cpp/ql/test/library-tests/dataflow/external-models/test.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,4 +396,18 @@ void forward_test_model() {
396396

397397
Element e = c.get();
398398
ymlSink(e.x); // $ ir
399+
}
400+
401+
struct ElementWithDefaultArgument {
402+
int x;
403+
ElementWithDefaultArgument(int x, int = 0);
404+
};
405+
406+
void forward_test_model_with_default_argument() {
407+
Container<ElementWithDefaultArgument> c;
408+
int x = ymlSource();
409+
c.emplace(0, x);
410+
411+
ElementWithDefaultArgument e = c.get();
412+
ymlSink(e.x); // $ MISSING: ir
399413
}

0 commit comments

Comments
 (0)