Skip to content

Commit 2cb8614

Browse files
committed
---
yaml --- r: 345815 b: refs/heads/master c: 9b42a82 h: refs/heads/master i: 345813: ad93c78 345811: 2647aff 345807: c311b29
1 parent e25589a commit 2cb8614

File tree

4 files changed

+99
-4
lines changed

4 files changed

+99
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: b8430af88c4d8cf3081dbcdeca62546fbe5972d3
2+
refs/heads/master: 9b42a82224c661b4b30adafb71ae2e2dfc5a0ca9
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/lib/AST/Decl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3210,6 +3210,7 @@ AssociatedTypeDecl *AssociatedTypeDecl::getAssociatedTypeAnchor() const {
32103210
// Find the best anchor among the anchors of the overridden decls.
32113211
AssociatedTypeDecl *bestAnchor = nullptr;
32123212
for (auto assocType : overridden) {
3213+
assert(this != assocType && "AssociatedTypeDecl cannot override itself");
32133214
auto anchor = assocType->getAssociatedTypeAnchor();
32143215
if (!bestAnchor || compare(anchor, bestAnchor) < 0)
32153216
bestAnchor = anchor;

trunk/lib/SILOptimizer/Transforms/AccessEnforcementReleaseSinking.cpp

Lines changed: 59 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,15 @@ static bool isBarrier(SILInstruction *inst) {
7474

7575
// Whitelist the safe builtin categories. Builtins should generally be
7676
// treated conservatively, because introducing a new builtin does not
77-
// require updating all passes to be aware of it. Avoid a default to ensure
78-
// that all categories are covered.
77+
// require updating all passes to be aware of it.
7978
switch (kind.getValue()) {
8079
case BuiltinValueKind::None:
8180
llvm_unreachable("Builtin must has a non-empty kind.");
81+
82+
// Unhandled categories don't generate a case. Instead, they result
83+
// in a build error: enumeration values not handled in switch.
84+
#define BUILTIN(Id, Name, Attrs)
85+
8286
#define BUILTIN_NO_BARRIER(Id) \
8387
case BuiltinValueKind::Id: \
8488
return false;
@@ -100,7 +104,59 @@ static bool isBarrier(SILInstruction *inst) {
100104
#define BUILTIN_RUNTIME_CALL(Id, Name, Attrs) \
101105
case BuiltinValueKind::Id: \
102106
return true; // A runtime call could be anything.
103-
#define BUILTIN_MISC_OPERATION(Id, Name, Attrs, Overload) BUILTIN_NO_BARRIER(Id)
107+
108+
// Handle BUILTIN_MISC_OPERATIONs individually.
109+
case BuiltinValueKind::Sizeof:
110+
case BuiltinValueKind::Strideof:
111+
case BuiltinValueKind::IsPOD:
112+
case BuiltinValueKind::IsBitwiseTakable:
113+
case BuiltinValueKind::IsSameMetatype:
114+
case BuiltinValueKind::Alignof:
115+
case BuiltinValueKind::OnFastPath:
116+
case BuiltinValueKind::ExtractElement:
117+
case BuiltinValueKind::InsertElement:
118+
case BuiltinValueKind::StaticReport:
119+
case BuiltinValueKind::AssertConf:
120+
case BuiltinValueKind::StringObjectOr:
121+
case BuiltinValueKind::UToSCheckedTrunc:
122+
case BuiltinValueKind::SToUCheckedTrunc:
123+
case BuiltinValueKind::SToSCheckedTrunc:
124+
case BuiltinValueKind::UToUCheckedTrunc:
125+
case BuiltinValueKind::SUCheckedConversion:
126+
case BuiltinValueKind::USCheckedConversion:
127+
case BuiltinValueKind::IntToFPWithOverflow:
128+
case BuiltinValueKind::ZeroInitializer:
129+
case BuiltinValueKind::Once:
130+
case BuiltinValueKind::OnceWithContext:
131+
case BuiltinValueKind::GetObjCTypeEncoding:
132+
case BuiltinValueKind::Swift3ImplicitObjCEntrypoint:
133+
case BuiltinValueKind::WillThrow:
134+
return false;
135+
136+
// Handle some rare builtins that may be sensitive to object lifetime
137+
// or deinit side effects conservatively.
138+
case BuiltinValueKind::AllocRaw:
139+
case BuiltinValueKind::DeallocRaw:
140+
case BuiltinValueKind::Fence:
141+
case BuiltinValueKind::AtomicLoad:
142+
case BuiltinValueKind::AtomicStore:
143+
case BuiltinValueKind::AtomicRMW:
144+
case BuiltinValueKind::Unreachable:
145+
case BuiltinValueKind::CmpXChg:
146+
case BuiltinValueKind::CondUnreachable:
147+
case BuiltinValueKind::DestroyArray:
148+
case BuiltinValueKind::CopyArray:
149+
case BuiltinValueKind::TakeArrayNoAlias:
150+
case BuiltinValueKind::TakeArrayFrontToBack:
151+
case BuiltinValueKind::TakeArrayBackToFront:
152+
case BuiltinValueKind::AssignCopyArrayNoAlias:
153+
case BuiltinValueKind::AssignCopyArrayFrontToBack:
154+
case BuiltinValueKind::AssignCopyArrayBackToFront:
155+
case BuiltinValueKind::AssignTakeArray:
156+
case BuiltinValueKind::UnsafeGuaranteed:
157+
case BuiltinValueKind::UnsafeGuaranteedEnd:
158+
return true;
159+
104160
#define BUILTIN_SANITIZER_OPERATION(Id, Name, Attrs) BUILTIN_NO_BARRIER(Id)
105161
#define BUILTIN_TYPE_CHECKER_OPERATION(Id, Name) BUILTIN_NO_BARRIER(Id)
106162
#define BUILTIN_TYPE_TRAIT_OPERATION(Id, Name) BUILTIN_NO_BARRIER(Id)

trunk/test/decl/func/operator.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,3 +359,41 @@ class C6 {
359359
if x == x && x = x { } // expected-error{{cannot convert value of type 'C6' to expected argument type 'Bool'}}
360360
}
361361
}
362+
363+
prefix operator
364+
365+
prefix func (arg: (Int, Int)) {}
366+
367+
func testPrefixOperatorOnTuple() {
368+
369+
let foo = (1, 2)
370+
_ = foo
371+
_ = ()foo
372+
// expected-error@-1 {{consecutive statements on a line must be separated by ';'}}
373+
// expected-warning@-2 {{expression of type '(Int, Int)' is unused}}
374+
_ = ()(foo)
375+
_ = (1, 2)
376+
_ = ()(1, 2) // expected-error {{operator function '∫' expects a single parameter of type '(Int, Int)'}}
377+
_ = ()((1, 2))
378+
}
379+
380+
postfix operator §
381+
382+
postfix func §<T, U>(arg: (T, (U, U), T)) {} // expected-note {{in call to operator '§'}}
383+
384+
func testPostfixOperatorOnTuple<A, B>(a: A, b: B) {
385+
386+
let foo = (a, (b, b), a)
387+
_ = foo§
388+
389+
// FIX-ME: "...could not be inferred" is irrelevant
390+
_ = (§)foo
391+
// expected-error@-1 {{consecutive statements on a line must be separated by ';'}}
392+
// expected-error@-2 {{generic parameter 'T' could not be inferred}}
393+
// expected-warning@-3 {{expression of type '(A, (B, B), A)' is unused}}
394+
_ = (§)(foo)
395+
_ = (a, (b, b), a)§
396+
_ = (§)(a, (b, b), a) // expected-error {{operator function '§' expects a single parameter of type '(T, (U, U), T)'}}
397+
_ = (§)((a, (b, b), a))
398+
_ = (a, ((), (b, (a, a), b)§), a)§
399+
}

0 commit comments

Comments
 (0)