Skip to content

Commit d061b09

Browse files
committed
C++: Test showing no support for != and !
1 parent 2729d10 commit d061b09

File tree

3 files changed

+131
-0
lines changed

3 files changed

+131
-0
lines changed

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/lowerBound.expected

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,37 @@
532532
| test.c:530:3:530:3 | i | -2147483648 |
533533
| test.c:530:10:530:11 | sc | 1 |
534534
| test.c:532:7:532:7 | i | -128 |
535+
| test.c:539:7:539:7 | n | 0 |
536+
| test.c:541:7:541:7 | n | 0 |
537+
| test.c:542:9:542:9 | n | 1 |
538+
| test.c:545:7:545:7 | n | 0 |
539+
| test.c:546:9:546:9 | n | 0 |
540+
| test.c:548:9:548:9 | n | 0 |
541+
| test.c:551:8:551:8 | n | 0 |
542+
| test.c:552:9:552:9 | n | 0 |
543+
| test.c:554:9:554:9 | n | 0 |
544+
| test.c:557:10:557:10 | n | 0 |
545+
| test.c:558:5:558:5 | n | 0 |
546+
| test.c:561:7:561:7 | n | 0 |
547+
| test.c:565:7:565:7 | n | -32768 |
548+
| test.c:568:7:568:7 | n | 0 |
549+
| test.c:569:9:569:9 | n | 0 |
550+
| test.c:571:9:571:9 | n | 0 |
551+
| test.c:574:7:574:7 | n | 0 |
552+
| test.c:575:9:575:9 | n | 0 |
553+
| test.c:577:9:577:9 | n | 0 |
554+
| test.c:580:10:580:10 | n | -32768 |
555+
| test.c:581:5:581:5 | n | -32768 |
556+
| test.c:584:7:584:7 | n | 0 |
557+
| test.c:588:7:588:7 | n | -32768 |
558+
| test.c:589:9:589:9 | n | -32768 |
559+
| test.c:590:11:590:11 | n | 0 |
560+
| test.c:594:7:594:7 | n | -32768 |
561+
| test.c:595:13:595:13 | n | 5 |
562+
| test.c:598:9:598:9 | n | 5 |
563+
| test.c:601:7:601:7 | n | -32768 |
564+
| test.c:601:22:601:22 | n | -32768 |
565+
| test.c:602:9:602:9 | n | -32768 |
535566
| test.cpp:10:7:10:7 | b | -2147483648 |
536567
| test.cpp:11:5:11:5 | x | -2147483648 |
537568
| test.cpp:13:10:13:10 | x | -2147483648 |

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/test.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,3 +533,72 @@ int mul_by_constant(int i, int j) {
533533

534534
return 0;
535535
}
536+
537+
538+
int notequal_type_endpoint(unsigned n) {
539+
out(n); // 0 ..
540+
541+
if (n > 0) {
542+
out(n); // 1 ..
543+
}
544+
545+
if (n != 0) {
546+
out(n); // 1 .. [BUG: lower bound is deduced to be 0]
547+
} else {
548+
out(n); // 0 .. 0
549+
}
550+
551+
if (!n) {
552+
out(n); // 0 .. 0
553+
} else {
554+
out(n); // 1 .. [BUG: lower bound is deduced to be 0]
555+
}
556+
557+
while (n != 0) {
558+
n--; // 1 .. [BUG: lower bound is deduced to be 0]
559+
}
560+
561+
out(n); // 0 .. 0
562+
}
563+
564+
void notequal_refinement(short n) {
565+
if (n < 0)
566+
return;
567+
568+
if (n == 0) {
569+
out(n); // 0 .. 0
570+
} else {
571+
out(n); // 1 .. [BUG: lower bound is deduced to be 0]
572+
}
573+
574+
if (n) {
575+
out(n); // 1 .. [BUG: lower bound is deduced to be 0]
576+
} else {
577+
out(n); // 0 .. 0
578+
}
579+
580+
while (n != 0) {
581+
n--; // 1 .. [BUG: lower bound is deduced to be -32768]
582+
}
583+
584+
out(n); // 0 .. 0
585+
}
586+
587+
void notequal_variations(short n, float f) {
588+
if (n != 0) {
589+
if (n >= 0) {
590+
out(n); // 1 .. [BUG: we can't handle `!=` coming first]
591+
}
592+
}
593+
594+
if (n >= 5) {
595+
if (2 * n - 10 == 0) { // Same as `n == 10/2` (modulo overflow)
596+
return;
597+
}
598+
out(n); // 6 .. [BUG: lower bound is deduced to be 5]
599+
}
600+
601+
if (n != -32768 && n != -32767) {
602+
out(n); // -32766 .. [BUG: lower bound is deduced to be -32768]
603+
}
604+
}

cpp/ql/test/library-tests/rangeanalysis/SimpleRangeAnalysis/upperBound.expected

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,37 @@
532532
| test.c:530:3:530:3 | i | 2147483647 |
533533
| test.c:530:10:530:11 | sc | 1 |
534534
| test.c:532:7:532:7 | i | 127 |
535+
| test.c:539:7:539:7 | n | 4294967295 |
536+
| test.c:541:7:541:7 | n | 4294967295 |
537+
| test.c:542:9:542:9 | n | 4294967295 |
538+
| test.c:545:7:545:7 | n | 4294967295 |
539+
| test.c:546:9:546:9 | n | 4294967295 |
540+
| test.c:548:9:548:9 | n | 0 |
541+
| test.c:551:8:551:8 | n | 4294967295 |
542+
| test.c:552:9:552:9 | n | 4294967295 |
543+
| test.c:554:9:554:9 | n | 4294967295 |
544+
| test.c:557:10:557:10 | n | 4294967295 |
545+
| test.c:558:5:558:5 | n | 4294967295 |
546+
| test.c:561:7:561:7 | n | 0 |
547+
| test.c:565:7:565:7 | n | 32767 |
548+
| test.c:568:7:568:7 | n | 32767 |
549+
| test.c:569:9:569:9 | n | 0 |
550+
| test.c:571:9:571:9 | n | 32767 |
551+
| test.c:574:7:574:7 | n | 32767 |
552+
| test.c:575:9:575:9 | n | 32767 |
553+
| test.c:577:9:577:9 | n | 32767 |
554+
| test.c:580:10:580:10 | n | 32767 |
555+
| test.c:581:5:581:5 | n | 32767 |
556+
| test.c:584:7:584:7 | n | 0 |
557+
| test.c:588:7:588:7 | n | 32767 |
558+
| test.c:589:9:589:9 | n | 32767 |
559+
| test.c:590:11:590:11 | n | 32767 |
560+
| test.c:594:7:594:7 | n | 32767 |
561+
| test.c:595:13:595:13 | n | 32767 |
562+
| test.c:598:9:598:9 | n | 32767 |
563+
| test.c:601:7:601:7 | n | 32767 |
564+
| test.c:601:22:601:22 | n | 32767 |
565+
| test.c:602:9:602:9 | n | 32767 |
535566
| test.cpp:10:7:10:7 | b | 2147483647 |
536567
| test.cpp:11:5:11:5 | x | 2147483647 |
537568
| test.cpp:13:10:13:10 | x | 2147483647 |

0 commit comments

Comments
 (0)