Skip to content

Commit ba32fd2

Browse files
authored
simplified sample code used to produce errors in tests (#7881)
1 parent 5ace300 commit ba32fd2

File tree

5 files changed

+133
-156
lines changed

5 files changed

+133
-156
lines changed

test/cli/other_test.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,7 @@ def test_def_undef(tmp_path):
21062106
void f()
21072107
{
21082108
#ifndef DEF_1
2109-
{int i = *((int*)0);}
2109+
(void)(*((int*)0));
21102110
#endif
21112111
}
21122112
""")
@@ -2124,7 +2124,7 @@ def test_def_undef(tmp_path):
21242124
'Checking {}: DEF_1=1...'.format(test_file) # TODO: should not print DEF_1 - see #13335
21252125
]
21262126
assert stderr.splitlines() == [
2127-
'{}:5:16: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
2127+
'{}:5:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
21282128
]
21292129

21302130

@@ -2136,10 +2136,10 @@ def test_def_def(tmp_path): # #13334
21362136
void f()
21372137
{
21382138
#if DEF_1 == 3
2139-
{int i = *((int*)0);}
2139+
(void)(*((int*)0));
21402140
#endif
21412141
#if DEF_1 == 7
2142-
{int i = *((int*)0);}
2142+
(void)(*((int*)0));
21432143
#endif
21442144
}
21452145
""")
@@ -2157,7 +2157,7 @@ def test_def_def(tmp_path): # #13334
21572157
'Checking {}: DEF_1=3;DEF_1=7...'.format(test_file) # TODO: should not print DEF_1 twice - see #13335
21582158
]
21592159
assert stderr.splitlines() == [
2160-
'{}:8:16: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
2160+
'{}:8:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
21612161
]
21622162

21632163

@@ -2169,7 +2169,7 @@ def test_def_undef_def(tmp_path): # #13334
21692169
void f()
21702170
{
21712171
#ifdef DEF_1
2172-
{int i = *((int*)0);}
2172+
(void)(*((int*)0));
21732173
#endif
21742174
}
21752175
""")
@@ -2188,7 +2188,7 @@ def test_def_undef_def(tmp_path): # #13334
21882188
'Checking {}: DEF_1=1;DEF_1=1...'.format(test_file) # TODO: should not print DEF_1 twice - see #13335
21892189
]
21902190
assert stderr.splitlines() == [
2191-
'{}:5:16: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
2191+
'{}:5:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
21922192
]
21932193

21942194

@@ -2199,7 +2199,7 @@ def test_undef(tmp_path):
21992199
void f()
22002200
{
22012201
#ifndef DEF_1
2202-
{int i = *((int*)0);}
2202+
(void)(*((int*)0));
22032203
#endif
22042204
}
22052205
""")
@@ -2215,7 +2215,7 @@ def test_undef(tmp_path):
22152215
'Checking {} ...'.format(test_file)
22162216
]
22172217
assert stderr.splitlines() == [
2218-
'{}:5:16: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
2218+
'{}:5:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
22192219
]
22202220

22212221

@@ -2229,7 +2229,7 @@ def test_undef_src(tmp_path): # #13340
22292229
void f()
22302230
{
22312231
#ifdef DEF_1
2232-
{int i = *((int*)0);}
2232+
(void)(*((int*)0));
22332233
#endif
22342234
}
22352235
""")
@@ -2245,7 +2245,7 @@ def test_undef_src(tmp_path): # #13340
22452245
'Checking {} ...'.format(test_file)
22462246
]
22472247
assert stderr.splitlines() == [
2248-
'{}:7:16: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
2248+
'{}:7:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
22492249
]
22502250

22512251

@@ -2644,7 +2644,7 @@ def test_debug(tmp_path):
26442644
f.write(
26452645
"""void f
26462646
{
2647-
(void)*((int*)0);
2647+
(void)(*((int*)0));
26482648
}
26492649
""")
26502650

@@ -2670,7 +2670,7 @@ def test_debug_xml(tmp_path):
26702670
f.write(
26712671
"""void f
26722672
{
2673-
(void)*((int*)0);
2673+
(void)(*((int*)0));
26742674
}
26752675
""")
26762676

@@ -2712,7 +2712,7 @@ def test_debug_verbose(tmp_path):
27122712
f.write(
27132713
"""void f
27142714
{
2715-
(void)*((int*)0);
2715+
(void)(*((int*)0));
27162716
}
27172717
""")
27182718

@@ -2739,7 +2739,7 @@ def test_debug_verbose_xml(tmp_path):
27392739
f.write(
27402740
"""void f
27412741
{
2742-
(void)*((int*)0);
2742+
(void)(*((int*)0));
27432743
}
27442744
""")
27452745

@@ -2785,7 +2785,7 @@ def __test_debug_template(tmp_path, verbose=False, debug=False):
27852785
"""template<class T> class TemplCl;
27862786
void f()
27872787
{
2788-
(void)*((int*)nullptr);
2788+
(void)(*((int*)nullptr));
27892789
}
27902790
""")
27912791

@@ -2824,7 +2824,7 @@ def __test_debug_template(tmp_path, verbose=False, debug=False):
28242824
else:
28252825
assert stdout.count('### Template Simplifier pass ') == 1
28262826
assert stderr.splitlines() == [
2827-
'{}:4:13: error: Null pointer dereference: (int*)nullptr [nullPointer]'.format(test_file)
2827+
'{}:4:14: error: Null pointer dereference: (int*)nullptr [nullPointer]'.format(test_file)
28282828
]
28292829
return stdout
28302830

@@ -3429,7 +3429,7 @@ def __test_debug_normal(tmp_path, verbose):
34293429
f.write(
34303430
"""void f()
34313431
{
3432-
(void)*((int*)0);
3432+
(void)(*((int*)0));
34333433
}
34343434
""")
34353435

@@ -3457,7 +3457,7 @@ def __test_debug_normal(tmp_path, verbose):
34573457
assert stdout.find('##AST') == -1
34583458
assert stdout.find('### Template Simplifier pass ') == -1
34593459
assert stderr.splitlines() == [
3460-
'{}:3:13: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
3460+
'{}:3:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
34613461
]
34623462
return stdout
34633463

@@ -3479,7 +3479,7 @@ def __test_debug_simplified(tmp_path, verbose):
34793479
f.write(
34803480
"""void f()
34813481
{
3482-
(void)*((int*)0);
3482+
(void)(*((int*)0));
34833483
}
34843484
""")
34853485

@@ -3501,7 +3501,7 @@ def __test_debug_simplified(tmp_path, verbose):
35013501
assert stdout.find('##AST') == -1
35023502
assert stdout.find('### Template Simplifier pass ') == -1
35033503
assert stderr.splitlines() == [
3504-
'{}:3:13: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
3504+
'{}:3:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
35053505
]
35063506
return stdout
35073507

@@ -3522,7 +3522,7 @@ def __test_debug_symdb(tmp_path, verbose):
35223522
f.write(
35233523
"""void f()
35243524
{
3525-
(void)*((int*)0);
3525+
(void)(*((int*)0));
35263526
}
35273527
""")
35283528

@@ -3544,7 +3544,7 @@ def __test_debug_symdb(tmp_path, verbose):
35443544
assert stdout.find('##AST') == -1
35453545
assert stdout.find('### Template Simplifier pass ') == -1
35463546
assert stderr.splitlines() == [
3547-
'{}:3:13: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
3547+
'{}:3:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
35483548
]
35493549
return stdout
35503550

@@ -3566,7 +3566,7 @@ def __test_debug_ast(tmp_path, verbose):
35663566
f.write(
35673567
"""void f()
35683568
{
3569-
(void)*((int*)0);
3569+
(void)(*((int*)0));
35703570
}
35713571
""")
35723572

@@ -3588,7 +3588,7 @@ def __test_debug_ast(tmp_path, verbose):
35883588
assert stdout.find('##AST') != -1
35893589
assert stdout.find('### Template Simplifier pass ') == -1
35903590
assert stderr.splitlines() == [
3591-
'{}:3:13: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
3591+
'{}:3:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
35923592
]
35933593
return stdout
35943594

@@ -3609,7 +3609,7 @@ def __test_debug_valueflow(tmp_path, verbose):
36093609
f.write(
36103610
"""void f()
36113611
{
3612-
(void)*((int*)0);
3612+
(void)(*((int*)0));
36133613
}
36143614
""")
36153615

@@ -3631,7 +3631,7 @@ def __test_debug_valueflow(tmp_path, verbose):
36313631
assert stdout.find('##AST') == -1
36323632
assert stdout.find('### Template Simplifier pass ') == -1
36333633
assert stderr.splitlines() == [
3634-
'{}:3:13: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
3634+
'{}:3:14: error: Null pointer dereference: (int*)0 [nullPointer]'.format(test_file)
36353635
]
36363636
return stdout
36373637

@@ -3653,7 +3653,7 @@ def test_debug_syntaxerror_c(tmp_path):
36533653
template<class T> class TemplCl;
36543654
void f()
36553655
{
3656-
(void)*((int*)0);
3656+
(void)(*((int*)0));
36573657
}
36583658
""")
36593659

0 commit comments

Comments
 (0)