-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[C2y] Add conformance test for WG14 N3364 #115332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic -emit-llvm -o - %s | ||
// RUN: %clang_cc1 -verify -Wall -pedantic -emit-llvm -o - %s | ||
// expected-no-diagnostics | ||
|
||
/* WG14 N3364: Yes | ||
* Give consistent wording for SNAN initialization v3 | ||
* | ||
* Ensure that initializing from a signaling NAN (optionally with a unary + or | ||
* -) at translation time behaves correctly at runtime. | ||
*/ | ||
|
||
#define FLT_SNAN __builtin_nansf("1") | ||
#define DBL_SNAN __builtin_nans("1") | ||
#define LD_SNAN __builtin_nansl("1") | ||
|
||
float f1 = FLT_SNAN; | ||
float f2 = +FLT_SNAN; | ||
float f3 = -FLT_SNAN; | ||
// CHECK: @f1 = {{.*}}global float 0x7FF0000020000000 | ||
// CHECK: @f2 = {{.*}}global float 0x7FF0000020000000 | ||
// CHECK: @f3 = {{.*}}global float 0xFFF0000020000000 | ||
|
||
double d1 = DBL_SNAN; | ||
double d2 = +DBL_SNAN; | ||
double d3 = -DBL_SNAN; | ||
// CHECK: @d1 = {{.*}}global double 0x7FF0000000000001 | ||
// CHECK: @d2 = {{.*}}global double 0x7FF0000000000001 | ||
// CHECK: @d3 = {{.*}}global double 0xFFF0000000000001 | ||
|
||
long double ld1 = LD_SNAN; | ||
long double ld2 = +LD_SNAN; | ||
long double ld3 = -LD_SNAN; | ||
// CHECK: @ld1 = {{.*}}global {{double 0x7FF0000000000001|x86_fp80 0xK7FFF8000000000000001|fp128 0xL00000000000000017FFF000000000000}} | ||
// CHECK: @ld2 = {{.*}}global {{double 0x7FF0000000000001|x86_fp80 0xK7FFF8000000000000001|fp128 0xL00000000000000017FFF000000000000}} | ||
// CHECK: @ld3 = {{.*}}global {{double 0xFFF0000000000001|x86_fp80 0xKFFFF8000000000000001|fp128 0xL0000000000000001FFFF000000000000}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jcranmer-intel : I recall seeing in the past that we sometimes print floats as scientific notation. Is this/the above in danger in any way because of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are sNaN values, which can't be emitted as a regular decimal floating-point literals. There is an outstanding patch right now to emit NaNs and infinities not in this special hexadecimal syntax (instead something like
nan(u0x1)
, syntax still somewhat TBD), but I would assume such a patch would adjust these test results as necessary.