Skip to content

Commit c1ead03

Browse files
authored
[C2y] Add conformance test for WG14 N3364 (#115332)
This paper is defining the translation-time behavior of initialization with a signaling NaN. Clang has always supported the correct behavior.
1 parent f58757b commit c1ead03

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ C2y Feature Support
293293
language modes but is now rejected (all of the other qualifiers and storage
294294
class specifiers were previously rejected).
295295

296+
- Updated conformance for `N3364 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3364.pdf>`_
297+
on floating-point translation-time initialization with signaling NaN. This
298+
paper adopts Clang's existing practice, so there were no changes to compiler
299+
behavior.
300+
296301
C23 Feature Support
297302
^^^^^^^^^^^^^^^^^^^
298303

clang/test/C/C2y/n3364.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic -emit-llvm -o - %s
2+
// RUN: %clang_cc1 -verify -Wall -pedantic -emit-llvm -o - %s
3+
// expected-no-diagnostics
4+
5+
/* WG14 N3364: Yes
6+
* Give consistent wording for SNAN initialization v3
7+
*
8+
* Ensure that initializing from a signaling NAN (optionally with a unary + or
9+
* -) at translation time behaves correctly at runtime.
10+
*/
11+
12+
#define FLT_SNAN __builtin_nansf("1")
13+
#define DBL_SNAN __builtin_nans("1")
14+
#define LD_SNAN __builtin_nansl("1")
15+
16+
float f1 = FLT_SNAN;
17+
float f2 = +FLT_SNAN;
18+
float f3 = -FLT_SNAN;
19+
// CHECK: @f1 = {{.*}}global float 0x7FF0000020000000
20+
// CHECK: @f2 = {{.*}}global float 0x7FF0000020000000
21+
// CHECK: @f3 = {{.*}}global float 0xFFF0000020000000
22+
23+
double d1 = DBL_SNAN;
24+
double d2 = +DBL_SNAN;
25+
double d3 = -DBL_SNAN;
26+
// CHECK: @d1 = {{.*}}global double 0x7FF0000000000001
27+
// CHECK: @d2 = {{.*}}global double 0x7FF0000000000001
28+
// CHECK: @d3 = {{.*}}global double 0xFFF0000000000001
29+
30+
long double ld1 = LD_SNAN;
31+
long double ld2 = +LD_SNAN;
32+
long double ld3 = -LD_SNAN;
33+
// CHECK: @ld1 = {{.*}}global {{double 0x7FF0000000000001|x86_fp80 0xK7FFF8000000000000001|fp128 0xL00000000000000017FFF000000000000}}
34+
// CHECK: @ld2 = {{.*}}global {{double 0x7FF0000000000001|x86_fp80 0xK7FFF8000000000000001|fp128 0xL00000000000000017FFF000000000000}}
35+
// CHECK: @ld3 = {{.*}}global {{double 0xFFF0000000000001|x86_fp80 0xKFFFF8000000000000001|fp128 0xL0000000000000001FFFF000000000000}}

clang/www/c_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ <h2 id="c2y">C2y implementation status</h2>
231231
<tr>
232232
<td>Give consistent wording for SNAN initialization v3</td>
233233
<td><a href="https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3364.pdf">N3364</a></td>
234-
<td class="unknown" align="center">Unknown</td>
234+
<td class="full" align="center">Yes</td>
235235
</tr>
236236
<tr>
237237
<td>Case range expressions v3.1</td>

0 commit comments

Comments
 (0)