Skip to content

Commit 0889d5d

Browse files
committed
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`.
1 parent 4324c97 commit 0889d5d

File tree

3 files changed

+25
-21
lines changed

3 files changed

+25
-21
lines changed

cpp/ql/test/library-tests/ir/ir/PrintAST.expected

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,13 @@ bad_asts.cpp:
193193
# 30| void Bad::errorExpr()
194194
# 30| params:
195195
# 30| body: { ... }
196-
# 31| 0: ExprStmt
197-
#-----| 0: <error expr>
198-
#-----| Type = error
199-
#-----| ValueCategory = prvalue(load)
196+
# 31| 0: declaration
197+
# 31| 0: definition of intref
198+
# 31| Type = int &
199+
# 31| init: initializer for intref
200+
# 31| expr: <error expr>
201+
# 31| Type = error
202+
# 31| ValueCategory = prvalue
200203
# 32| 1: declaration
201204
# 32| 0: definition of x
202205
# 32| Type = int

cpp/ql/test/library-tests/ir/ir/bad_asts.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace Bad {
2828
}
2929

3030
void errorExpr() {
31-
0 = 1;
31+
int &intref = 0;
3232
int x = 0[0];
3333
x = 1[1];
3434
}

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,23 @@ bad_asts.cpp:
5050

5151
# 30| void Bad::errorExpr()
5252
# 30| Block 0
53-
# 30| v0_0(void) = EnterFunction :
54-
# 30| mu0_1(unknown) = AliasedDefinition :
55-
# 30| mu0_2(unknown) = UnmodeledDefinition :
56-
#-----| r0_3(glval<error>) = Error :
57-
#-----| r0_4(error) = Load : &:r0_3, ~mu0_2
58-
# 32| r0_5(glval<int>) = VariableAddress[x] :
59-
# 32| r0_6(error) = Error :
60-
# 32| mu0_7(int) = Store : &:r0_5, r0_6
61-
#-----| r0_8(glval<error>) = Error :
62-
#-----| r0_9(error) = Load : &:r0_8, ~mu0_2
63-
# 33| r0_10(glval<int>) = VariableAddress[x] :
64-
# 33| mu0_11(int) = Store : &:r0_10, r0_9
65-
# 34| v0_12(void) = NoOp :
66-
# 30| v0_13(void) = ReturnVoid :
67-
# 30| v0_14(void) = UnmodeledUse : mu*
68-
# 30| v0_15(void) = ExitFunction :
53+
# 30| v0_0(void) = EnterFunction :
54+
# 30| mu0_1(unknown) = AliasedDefinition :
55+
# 30| mu0_2(unknown) = UnmodeledDefinition :
56+
# 31| r0_3(glval<int &>) = VariableAddress[intref] :
57+
# 31| r0_4(error) = Error :
58+
# 31| mu0_5(int &) = Store : &:r0_3, r0_4
59+
# 32| r0_6(glval<int>) = VariableAddress[x] :
60+
# 32| r0_7(error) = Error :
61+
# 32| mu0_8(int) = Store : &:r0_6, r0_7
62+
#-----| r0_9(glval<error>) = Error :
63+
#-----| r0_10(error) = Load : &:r0_9, ~mu0_2
64+
# 33| r0_11(glval<int>) = VariableAddress[x] :
65+
# 33| mu0_12(int) = Store : &:r0_11, r0_10
66+
# 34| v0_13(void) = NoOp :
67+
# 30| v0_14(void) = ReturnVoid :
68+
# 30| v0_15(void) = UnmodeledUse : mu*
69+
# 30| v0_16(void) = ExitFunction :
6970

7071
clang.cpp:
7172
# 5| int* globalIntAddress()

0 commit comments

Comments
 (0)