Skip to content

[stdlib] Explicitly mark Float80 unavailable, when it is #13305

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 3 commits into from
Jan 4, 2018

Conversation

Dante-Broggi
Copy link
Contributor

This PR causes a Float80 type to be explicitly marked unavailable, instead of being simply absent.
It also adds extra conditionals to not generate #ifs within an #if checking the same condition.

Resolves SR-6009.

I think I did everything, but this is my first contribution to swift.

 and cause identical `#if`s to not be nested
@Dante-Broggi Dante-Broggi changed the title Explicitly mark Float80 unavailable, when it is [stdlib] Explicitly mark Float80 unavailable, when it is Dec 6, 2017
Copy link
Contributor

@stephentyrone stephentyrone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Dante-Broggi, welcome to Swift and thanks for looking at this; a few minor questions to ask...

@@ -1519,7 +1523,7 @@ extension ${Self} {
% srcBits = src_type.bits
% That = src_type.stdlib_name

% if srcBits == 80:
% if (srcBits == 80) and (bits != 80):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this piece of the change does anything; what is your goal here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just syntactically annoyed that the existing implementation has:
#if !os(windows) && (arch(i386) || arch(x86_64))
//code
#if !os(windows) && (arch(i386) || arch(x86_64))
//code
#endif
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, ok. Generally best to skip this sort of change-that-doesn't-really-change-anything, but it is a modest improvement and you've already done it, so let's take it.

@@ -1721,6 +1725,18 @@ extension ${Self} {
}

% if bits == 80:
#else
${SelfDocComment}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix-up the indentation here. Also, @moiseev, do we want @_transparent, etc on a dummy object like this?

@@ -1354,7 +1354,9 @@ extension ${Self} : _ExpressibleByBuiltinIntegerLiteral, ExpressibleByIntegerLit
}
}

% if bits != 80:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the goal of adding the new check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was just syntactically annoyed that the existing gyb implementation outputs:
#if !os(windows) && (arch(i386) || arch(x86_64))
//code
#if !os(windows) && (arch(i386) || arch(x86_64))
//code
#endif
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's difficult to see what's going on here in GitHub diff form, I'll need to look at this more carefully.


${SelfDocComment}
@_fixed_layout
@available(*, unavailable, message: "available only #if !os(Windows) && (arch(i386) || arch(x86_64))")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably make the error message a little more approachable; something like "Float80 is only available on non-Windows x86 targets." What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really had no idea of how (arch(i386) || arch(x86_64)) would map to reader-friendly text, so I just put the code one would need to verify Float80 was actually available.
Putting your suggestion in.

@@ -1519,7 +1523,7 @@ extension ${Self} {
% srcBits = src_type.bits
% That = src_type.stdlib_name

% if srcBits == 80:
% if (srcBits == 80) and (bits != 80):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, ok. Generally best to skip this sort of change-that-doesn't-really-change-anything, but it is a modest improvement and you've already done it, so let's take it.

@@ -1354,7 +1354,9 @@ extension ${Self} : _ExpressibleByBuiltinIntegerLiteral, ExpressibleByIntegerLit
}
}

% if bits != 80:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's difficult to see what's going on here in GitHub diff form, I'll need to look at this more carefully.

@moiseev
Copy link
Contributor

moiseev commented Jan 4, 2018

@swift-ci Please smoke test and merge

@moiseev
Copy link
Contributor

moiseev commented Jan 4, 2018

Thanks @Dante-Broggi!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants