Skip to content

Commit a6d1685

Browse files
[compiler-rt][ubsan] Refactor cast-overflow test
1 parent 31bf16a commit a6d1685

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
// RUN: %run %t 4 2>&1 | FileCheck %s --check-prefix=CHECK-4
88
// RUN: %run %t 5 2>&1 | FileCheck %s --check-prefix=CHECK-5
99
// RUN: %run %t 6 2>&1 | FileCheck %s --check-prefix=CHECK-6
10-
// FIXME: %run %t 7 2>&1 | FileCheck %s --check-prefix=CHECK-7
11-
// FIXME: not %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8
12-
// RUN: not %run %t 9 2>&1 | FileCheck %s --check-prefix=CHECK-9
10+
// RUN: %run %t 7 2>&1 | FileCheck %s --check-prefix=CHECK-7
1311

1412
// Issue #41838
1513
// XFAIL: sparc-target-arch && target={{.*solaris.*}}
@@ -151,20 +149,13 @@ int main(int argc, char **argv) {
151149
return 0;
152150
#endif
153151
}
154-
// FIXME: The backend cannot lower __fp16 operations on x86 yet.
155-
//case '7':
156-
// (__fp16)65504; // ok
157-
// // CHECK-7: runtime error: 65505 is outside the range of representable values of type '__fp16'
158-
// return (__fp16)65505;
159-
160-
// Floating point -> floating point overflow.
161-
case '8':
162-
// CHECK-8: {{.*}}cast-overflow.cpp:[[@LINE+1]]:19: runtime error: 1e+39 is outside the range of representable values of type 'float'
163-
return (float)1e39;
164-
case '9':
152+
case '7': {
165153
volatile long double ld = 300.0;
166-
// CHECK-9: {{.*}}cast-overflow.cpp:[[@LINE+1]]:14: runtime error: 300 is outside the range of representable values of type 'char'
154+
// CHECK-7: {{.*}}cast-overflow.cpp:[[@LINE+1]]:14: runtime error: 300 is outside the range of representable values of type 'char'
167155
char c = ld;
168-
return c;
156+
// `c` is allowed to contain UNDEF, thus we should not use
157+
// its value as an exit code.
158+
return 0;
159+
}
169160
}
170161
}

0 commit comments

Comments
 (0)