Files
codeql/cpp/ql/test/library-tests/ir/ir/bad_asts.cpp
Jonas Jensen 0889d5d27a C++ IR: Improve ErrorExpr test
The previous version of the test used `0 = 1;` to test an lvalue-typed
`ErrorExpr`, but the extractor replaced the whole assignment expression
with `ErrorExpr` instead of just the LHS. This variation of the test
only leads to an `ErrorExpr` for the part of the syntax that's supposed
to be an lvalue-typed expression, so that's an improvement.
Unfortunately it still doesn't demonstrate that we can `Store` into an
address computed by an `ErrorExpr`.
2019-07-09 13:35:20 +02:00

36 lines
677 B
C++

// semmle-extractor-options: -std=c++17 --expect_errors
// Test cases that illustrate known bad ASTs that we have to work around in IR generation.
namespace Bad {
struct S {
int x;
template<int t>
int MemberFunction(int y) {
return t + x + y;
}
};
void CallBadMemberFunction() {
S s = {};
s.MemberFunction<6>(1); // Not marked as member function in AST.
}
struct Point {
int x;
int y;
Point() {
}
};
void CallCopyConstructor(const Point& a) {
Point b = a; // Copy constructor contains literal expressions with no values.
}
void errorExpr() {
int &intref = 0;
int x = 0[0];
x = 1[1];
}
}