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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions stdlib/public/core/FloatingPointTypes.swift.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -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.

#if !os(Windows) && (arch(i386) || arch(x86_64))
% end

% builtinFloatLiteralBits = 80
extension ${Self} : _ExpressibleByBuiltinFloatLiteral {
Expand All @@ -1373,6 +1375,7 @@ extension ${Self} : _ExpressibleByBuiltinFloatLiteral {
}
}

% if bits != 80:
#else

% builtinFloatLiteralBits = 64
Expand All @@ -1393,6 +1396,7 @@ extension ${Self} : _ExpressibleByBuiltinFloatLiteral {
}

#endif
% end

extension ${Self} : Hashable {
/// The number's hash value.
Expand Down Expand Up @@ -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.

#if !os(Windows) && (arch(i386) || arch(x86_64))
% end

Expand Down Expand Up @@ -1584,7 +1588,7 @@ extension ${Self} {
}
}

% if srcBits == 80:
% if (srcBits == 80) and (bits != 80):
#endif
% end
% end
Expand Down Expand Up @@ -1721,6 +1725,20 @@ extension ${Self} {
}

% if bits == 80:
#else

${SelfDocComment}
@_fixed_layout
@available(*, unavailable, message: "Float80 is only available on non-Windows x86 targets.")
public struct ${Self} {
/// Creates a value initialized to zero.
@_inlineable // FIXME(sil-serialize-all)
@_transparent
public init() {
fatalError("${Self} is not available")
}
}

#endif
% end
% end # for bits in all_floating_point_types
Expand Down