Skip to content

Commit 0e5c44e

Browse files
committed
C++: Add new test for conversions.
1 parent e89e99d commit 0e5c44e

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
void Conversion4(int x) {
22
x = ((int)7);
3+
}
4+
5+
char * retfn(void * v) {
6+
return (char*)(void*)(int*)v;
7+
}
8+
9+
void Conversion4_vardecl(int x) {
10+
long y = (long) x;
311
}

cpp/ql/test/examples/expressions/PrintAST.expected

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,44 @@ Conversion4.c:
349349
# 2| Value = [Literal] 7
350350
# 2| ValueCategory = prvalue
351351
# 3| 1: [ReturnStmt] return ...
352+
# 5| [TopLevelFunction] char* retfn(void*)
353+
# 5| params:
354+
# 5| 0: [Parameter] v
355+
# 5| Type = [VoidPointerType] void *
356+
# 5| body: [BlockStmt] { ... }
357+
# 6| 0: [ReturnStmt] return ...
358+
# 6| 0: [CStyleCast] (char *)...
359+
# 6| Conversion = [PointerConversion] pointer conversion
360+
# 6| Type = [CharPointerType] char *
361+
# 6| ValueCategory = prvalue
362+
# 6| expr: [CStyleCast] (void *)...
363+
# 6| Conversion = [PointerConversion] pointer conversion
364+
# 6| Type = [VoidPointerType] void *
365+
# 6| ValueCategory = prvalue
366+
# 6| expr: [CStyleCast] (int *)...
367+
# 6| Conversion = [PointerConversion] pointer conversion
368+
# 6| Type = [IntPointerType] int *
369+
# 6| ValueCategory = prvalue
370+
# 6| expr: [VariableAccess] v
371+
# 6| Type = [VoidPointerType] void *
372+
# 6| ValueCategory = prvalue(load)
373+
# 9| [TopLevelFunction] void Conversion4_vardecl(int)
374+
# 9| params:
375+
# 9| 0: [Parameter] x
376+
# 9| Type = [IntType] int
377+
# 9| body: [BlockStmt] { ... }
378+
# 10| 0: [DeclStmt] declaration
379+
# 10| 0: [VariableDeclarationEntry] definition of y
380+
# 10| Type = [LongType] long
381+
# 10| init: [Initializer] initializer for y
382+
# 10| expr: [CStyleCast] (long)...
383+
# 10| Conversion = [IntegralConversion] integral conversion
384+
# 10| Type = [LongType] long
385+
# 10| ValueCategory = prvalue
386+
# 10| expr: [VariableAccess] x
387+
# 10| Type = [IntType] int
388+
# 10| ValueCategory = prvalue(load)
389+
# 11| 1: [ReturnStmt] return ...
352390
DestructorCall.cpp:
353391
# 1| [Constructor] void C::C()
354392
# 1| params:

0 commit comments

Comments
 (0)