Skip to content

Commit 7082f65

Browse files
authored
Merge pull request #17972 from rudkx/fix-verification-of-pointer-conversions
Partial fix for verification of where pointer conversions can appear.
2 parents c3867c8 + 7798b9f commit 7082f65

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/AST/ASTVerifier.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -1469,7 +1469,9 @@ class Verifier : public ASTWalker {
14691469
}
14701470
};
14711471

1472-
// These outer entities will be interleaved in multi-level optionals.
1472+
// FIXME: This doesn't seem like a particularly robust
1473+
// approach to tracking whether pointer conversions
1474+
// always appear as call arguments.
14731475
while (true) {
14741476
// Look through optional evaluations.
14751477
if (auto *optionalEval = dyn_cast<OptionalEvaluationExpr>(subExpr)) {
@@ -1484,6 +1486,17 @@ class Verifier : public ASTWalker {
14841486
continue;
14851487
}
14861488

1489+
// FIXME: This is only handling the value conversion, not
1490+
// the key conversion. What this verifier check
1491+
// should probably do is just track whether we're
1492+
// currently visiting arguments of an apply when we
1493+
// find these conversions.
1494+
if (auto *upcast =
1495+
dyn_cast<CollectionUpcastConversionExpr>(subExpr)) {
1496+
subExpr = upcast->getValueConversion().Conversion;
1497+
continue;
1498+
}
1499+
14871500
break;
14881501
}
14891502

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
func foo(_ a: [[UInt8]], _ p: [UnsafeRawPointer]) {
4+
foo(a, a) // expect-warning {{all paths through this function will call itself}}
5+
}

0 commit comments

Comments
 (0)