Skip to content

Commit 43f2c9e

Browse files
Merge pull request #4483 from swiftwasm/main
[pull] swiftwasm from main
2 parents 7af6775 + 9e54917 commit 43f2c9e

File tree

14 files changed

+59
-59
lines changed

14 files changed

+59
-59
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ ERROR(missing_address_of_yield,none,
12061206
"yielding mutable value of type %0 requires explicit '&'",
12071207
(Type))
12081208
ERROR(extraneous_address_of,none,
1209-
"use of extraneous '&'",
1209+
"'&' may only be used to pass an argument to inout parameter",
12101210
())
12111211
ERROR(extra_address_of,none,
12121212
"'&' used with non-inout argument of type %0",

stdlib/public/CommandLineSupport/CommandLine.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,25 +124,27 @@ char **_swift_stdlib_getUnsafeArgvArgc(int *outArgLen) {
124124
if (szBufferSize == 0) {
125125
swift::fatalError(0,
126126
"Fatal error: Could not retrieve commandline "
127-
"arguments: %u\n",
128-
GetLastError());
127+
"argument %d: %lu\n",
128+
i, GetLastError());
129129
return nullptr;
130130
}
131131

132132
char *buffer = static_cast<char *>(
133133
calloc(static_cast<size_t>(szBufferSize), sizeof(char)));
134134
if (buffer == nullptr) {
135135
swift::fatalError(0,
136-
"Fatal error: Could not allocate space for commandline"
137-
"arguments");
136+
"Fatal error: Could not allocate space for commandline "
137+
"argument %d: %d\n",
138+
i, errno);
138139
return nullptr;
139140
}
140141

141142
if (!WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, szArgList[i], -1,
142143
buffer, szBufferSize, nullptr, nullptr)) {
143144
swift::fatalError(0,
144145
"Fatal error: Conversion to UTF-8 failed for "
145-
"commandline arguments");
146+
"commandline argument %d: %lu\n",
147+
i, GetLastError());
146148
return nullptr;
147149
}
148150

stdlib/public/Concurrency/Task.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,23 +1265,21 @@ static void swift_task_asyncMainDrainQueueImpl() {
12651265
"swift_task_asyncMainDrainQueue");
12661266
#else
12671267
#if defined(_WIN32)
1268-
static void(FAR *pfndispatch_main)(void) = NULL;
1269-
1270-
if (pfndispatch_main)
1271-
return pfndispatch_main();
1272-
12731268
HMODULE hModule = LoadLibraryW(L"dispatch.dll");
1274-
if (hModule == NULL)
1275-
swift_reportError(0, "unable to load dispatch.dll");
1269+
if (hModule == NULL) {
1270+
swift_Concurrency_fatalError(0,
1271+
"unable to load dispatch.dll: %lu", GetLastError());
1272+
}
12761273

1277-
pfndispatch_main =
1278-
reinterpret_cast<void (FAR *)(void)>(GetProcAddress(hModule,
1279-
"dispatch_main"));
1280-
if (pfndispatch_main == NULL)
1281-
swift_reportError(0, "unable to locate dispatch_main in dispatch.dll");
1274+
auto pfndispatch_main = reinterpret_cast<void (FAR *)(void)>(
1275+
GetProcAddress(hModule, "dispatch_main"));
1276+
if (pfndispatch_main == NULL) {
1277+
swift_Concurrency_fatalError(0,
1278+
"unable to locate dispatch_main in dispatch.dll: %lu", GetLastError());
1279+
}
12821280

12831281
pfndispatch_main();
1284-
exit(0);
1282+
swift_unreachable("Returned from dispatch_main()");
12851283
#else
12861284
// CFRunLoop is not available on non-Darwin targets. Foundation has an
12871285
// implementation, but CoreFoundation is not meant to be exposed. We can only

stdlib/public/stubs/Random.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void swift_stdlib_random(void *buf, __swift_size_t nbytes) {
7070
static_cast<ULONG>(nbytes),
7171
BCRYPT_USE_SYSTEM_PREFERRED_RNG);
7272
if (!BCRYPT_SUCCESS(status)) {
73-
fatalError(0, "Fatal error: 0x%.8X in '%s'\n", status, __func__);
73+
fatalError(0, "Fatal error: 0x%lX in '%s'\n", status, __func__);
7474
}
7575
}
7676

test/Constraints/diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ func testTypeSugar(_ a : Int) {
453453

454454
// <rdar://problem/21974772> SegFault in FailureDiagnosis::visitInOutExpr
455455
func r21974772(_ y : Int) {
456-
let x = &(1.0 + y) // expected-error {{use of extraneous '&'}}
456+
let x = &(1.0 + y) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
457457
}
458458

459459
// <rdar://problem/22020088> QoI: missing member diagnostic on optional gives worse error message than existential/bound generic/etc

test/Constraints/lvalues.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ func testInOut(_ arg: inout Int) {
159159
}
160160

161161
// Don't infer inout types.
162-
var ir = &i // expected-error {{use of extraneous '&'}}
163-
var ir2 = ((&i)) // expected-error {{use of extraneous '&'}}
162+
var ir = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
163+
var ir2 = ((&i)) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
164164

165165
// <rdar://problem/17133089>
166166
func takeArrayRef(_ x: inout Array<String>) { }
@@ -279,10 +279,10 @@ func look_through_parens_when_checking_inout() {
279279
func modifyPoint(source: inout Point) {}
280280

281281
var point = Point(x: 0, y: 0)
282-
modifyPoint((&point)) // expected-error {{use of extraneous '&}} {{16-17=(}} {{15-16=&}}
283-
modifyPoint(((&point))) // expected-error {{use of extraneous '&}} {{17-18=(}} {{15-16=&}}
284-
modifyPoint(source: (&point)) // expected-error {{use of extraneous '&}} {{24-25=(}} {{23-24=&}}
285-
modifyPoint(source: ((&point))) // expected-error {{use of extraneous '&}} {{25-26=(}} {{23-24=&}}
286-
modifyPoint((&point), 0) // expected-error {{use of extraneous '&}} {{16-17=(}} {{15-16=&}}
287-
modifyPoint((&point), msg: "") // expected-error {{use of extraneous '&}} {{16-17=(}} {{15-16=&}}
282+
modifyPoint((&point)) // expected-error {{'&' may only be used to pass an argument to inout parameter}} {{16-17=(}} {{15-16=&}}
283+
modifyPoint(((&point))) // expected-error {{'&' may only be used to pass an argument to inout parameter}} {{17-18=(}} {{15-16=&}}
284+
modifyPoint(source: (&point)) // expected-error {{'&' may only be used to pass an argument to inout parameter}} {{24-25=(}} {{23-24=&}}
285+
modifyPoint(source: ((&point))) // expected-error {{'&' may only be used to pass an argument to inout parameter}} {{25-26=(}} {{23-24=&}}
286+
modifyPoint((&point), 0) // expected-error {{'&' may only be used to pass an argument to inout parameter}} {{16-17=(}} {{15-16=&}}
287+
modifyPoint((&point), msg: "") // expected-error {{'&' may only be used to pass an argument to inout parameter}} {{16-17=(}} {{15-16=&}}
288288
}

test/Constraints/optional.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,17 +470,17 @@ func rdar75146811() {
470470
var arr: [Double]! = []
471471

472472
test(&arr) // expected-error {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
473-
test((&arr)) // expected-error {{use of extraneous '&'}}
473+
test((&arr)) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
474474
// expected-error@-1 {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
475475
test(&(arr)) // expected-error {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
476476

477477
test_tuple(&arr, x: 0) // expected-error {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
478-
test_tuple((&arr), x: 0) // expected-error {{use of extraneous '&'}}
478+
test_tuple((&arr), x: 0) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
479479
// expected-error@-1 {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
480480
test_tuple(&(arr), x: 0) // expected-error {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
481481

482482
test_named(x: &arr) // expected-error {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
483-
test_named(x: (&arr)) // expected-error {{use of extraneous '&'}}
483+
test_named(x: (&arr)) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
484484
// expected-error@-1 {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
485485
test_named(x: &(arr)) // expected-error {{cannot convert value of type '[Double]?' to expected argument type 'Double'}}
486486
}

test/Parse/pointer_conversion.swift.gyb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ func mutablePointerArguments(_ p: UnsafeMutablePointer<Int>,
6565
takesMutableArrayPointer(&ii)
6666

6767
// We don't allow these conversions outside of function arguments.
68-
var x: UnsafeMutablePointer<Int> = &i // expected-error {{use of extraneous '&'}}
69-
x = &ii // expected-error {{use of extraneous '&'}}
68+
var x: UnsafeMutablePointer<Int> = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
69+
x = &ii // expected-error {{'&' may only be used to pass an argument to inout parameter}}
7070
_ = x
7171
}
7272

@@ -97,9 +97,9 @@ func mutableVoidPointerArguments(_ p: UnsafeMutablePointer<Int>,
9797
takesMutableVoidPointer(ff) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
9898

9999
// We don't allow these conversions outside of function arguments.
100-
var x: UnsafeMutableRawPointer = &i // expected-error {{use of extraneous '&'}}
100+
var x: UnsafeMutableRawPointer = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
101101
x = p // expected-error{{cannot assign value of type 'UnsafeMutablePointer<Int>' to type 'UnsafeMutableRawPointer'}}
102-
x = &ii // expected-error {{use of extraneous '&'}}
102+
x = &ii // expected-error {{'&' may only be used to pass an argument to inout parameter}}
103103
_ = x
104104
}
105105

@@ -132,9 +132,9 @@ func mutableRawPointerArguments(_ p: UnsafeMutablePointer<Int>,
132132
takesMutableRawPointer(ff) // expected-error{{cannot convert value of type '[Int]' to expected argument type 'UnsafeMutableRawPointer${diag_suffix}'}}
133133

134134
// We don't allow these conversions outside of function arguments.
135-
var x: UnsafeMutableRawPointer = &i // expected-error {{use of extraneous '&'}}
135+
var x: UnsafeMutableRawPointer = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
136136
x = p // expected-error{{cannot assign value of type 'UnsafeMutablePointer<Int>' to type 'UnsafeMutableRawPointer'}}
137-
x = &ii //expected-error {{use of extraneous '&'}}
137+
x = &ii //expected-error {{'&' may only be used to pass an argument to inout parameter}}
138138
_ = x
139139
}
140140

@@ -167,7 +167,7 @@ func constPointerArguments(_ p: UnsafeMutablePointer<Int>,
167167
// expected-error@-1 3 {{cannot convert value of type 'Double' to expected element type 'Int'}}
168168

169169
// We don't allow these conversions outside of function arguments.
170-
var x: UnsafePointer<Int> = &i // expected-error {{use of extraneous '&'}}
170+
var x: UnsafePointer<Int> = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
171171
x = ii // expected-error{{cannot assign value of type '[Int]' to type 'UnsafePointer<Int>'}}
172172
x = p // expected-error{{cannot assign value of type 'UnsafeMutablePointer<Int>' to type 'UnsafePointer<Int>'}}
173173
}
@@ -201,7 +201,7 @@ func constVoidPointerArguments(_ p: UnsafeMutablePointer<Int>,
201201
takesConstVoidPointer([0.0, 1.0, 2.0])
202202

203203
// We don't allow these conversions outside of function arguments.
204-
var x: UnsafeRawPointer = &i // expected-error {{use of extraneous '&'}}
204+
var x: UnsafeRawPointer = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
205205
x = ii // expected-error{{cannot assign value of type '[Int]' to type 'UnsafeRawPointer'}}
206206
x = p // expected-error{{cannot assign value of type 'UnsafeMutablePointer<Int>' to type 'UnsafeRawPointer'}}
207207
x = fp // expected-error{{cannot assign value of type 'UnsafeMutablePointer<Float>' to type 'UnsafeRawPointer'}}
@@ -241,7 +241,7 @@ func constRawPointerArguments(_ p: UnsafeMutablePointer<Int>,
241241
takesConstRawPointer([0.0, 1.0, 2.0])
242242

243243
// We don't allow these conversions outside of function arguments.
244-
var x: UnsafeRawPointer = &i // expected-error {{use of extraneous '&'}}
244+
var x: UnsafeRawPointer = &i // expected-error {{'&' may only be used to pass an argument to inout parameter}}
245245
x = ii // expected-error{{cannot assign value of type '[Int]' to type 'UnsafeRawPointer'}}
246246
x = p // expected-error{{cannot assign value of type 'UnsafeMutablePointer<Int>' to type 'UnsafeRawPointer'}}
247247
x = fp // expected-error{{cannot assign value of type 'UnsafeMutablePointer<Float>' to type 'UnsafeRawPointer'}}

test/Parse/pointer_conversion_objc.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,5 @@ func autoreleasingPointerArguments(p: UnsafeMutablePointer<Int>,
7272
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('[C]' and 'C') are expected to be equal}}
7373
takesAutoreleasingPointer(&dd) // expected-error{{cannot convert value of type 'AutoreleasingUnsafeMutablePointer<[D]>' to expected argument type 'AutoreleasingUnsafeMutablePointer<C>'}}
7474
// expected-note@-1 {{arguments to generic parameter 'Pointee' ('[D]' and 'C') are expected to be equal}}
75-
let _: AutoreleasingUnsafeMutablePointer<C> = &c // expected-error {{use of extraneous '&'}}
75+
let _: AutoreleasingUnsafeMutablePointer<C> = &c // expected-error {{'&' may only be used to pass an argument to inout parameter}}
7676
}

test/Parse/recovery.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ func test23550816(ss: [String], s: String) {
816816
// <rdar://problem/23719432> [practicalswift] Compiler crashes on &(Int:_)
817817
func test23719432() {
818818
var x = 42
819-
&(Int:x) // expected-error {{use of extraneous '&'}}
819+
&(Int:x) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
820820
}
821821

822822
// <rdar://problem/19911096> QoI: terrible recovery when using '·' for an operator

test/Sema/diag_invalid_interpolation_4_2.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ _ = "\(y: &x)"
1010
// expected-note@-3 {{remove 'y' label to keep current behavior}}
1111

1212
_ = "\(x, y: &x)"
13-
// expected-error@-1 {{use of extraneous '&'}}
13+
// expected-error@-1 {{'&' may only be used to pass an argument to inout parameter}}
1414
// expected-warning@-2 {{interpolating multiple values will not form a tuple in Swift 5}}
1515
// expected-note@-3 {{insert parentheses to keep current behavior}}

test/TypeCoercion/overload_noncall.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func test_inout() {
5252
x = accept_XY(&xy);
5353

5454
x = xy
55-
x = &xy; // expected-error {{use of extraneous '&'}}
55+
x = &xy; // expected-error {{'&' may only be used to pass an argument to inout parameter}}
5656
accept_Z(&xy); // expected-error{{cannot convert value of type 'X' to expected argument type 'Z'}}
5757
}
5858

test/decl/func/default-values.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,10 @@ func inoutFuncWithDefaultArg1(x: inout Int = 1) {} // expected-error {{cannot pr
132132
func inoutFuncWithDefaultArg2(x: inout Int = bLiteral) {} // expected-error {{cannot provide default value to inout parameter 'x'}}
133133
func inoutFuncWithDefaultArg3(x: inout Int = aLiteral) {} // expected-error {{cannot provide default value to inout parameter 'x'}}
134134
func inoutFuncWithDefaultArg4(x: inout Int = &aLiteral) {} // expected-error {{cannot provide default value to inout parameter 'x'}}
135-
// expected-error@-1 {{use of extraneous '&'}}
135+
// expected-error@-1 {{'&' may only be used to pass an argument to inout parameter}}
136136

137137
func inoutFuncWithDefaultArg5(x: inout Int = &bLiteral) {} // expected-error {{cannot provide default value to inout parameter 'x'}}
138-
// expected-error@-1 {{use of extraneous '&'}}
138+
// expected-error@-1 {{'&' may only be used to pass an argument to inout parameter}}
139139

140140
func inoutFuncWithDefaultArg6(x: inout Int = #file) {} // expected-error {{cannot provide default value to inout parameter 'x'}}
141141
// expected-error@-1 {{default argument value of type 'String' cannot be converted to type 'Int'}}

test/expr/expressions.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,8 @@ func testInOut(_ arg: inout Int) {
542542
takesExplicitInt(x) // expected-error{{passing value of type 'Int' to an inout parameter requires explicit '&'}} {{20-20=&}}
543543
takesExplicitInt(&x)
544544
takesInt(&x) // expected-error{{'&' used with non-inout argument of type 'Int'}}
545-
var y = &x //expected-error {{use of extraneous '&'}}
546-
var z = &arg //expected-error {{use of extraneous '&'}}
545+
var y = &x //expected-error {{'&' may only be used to pass an argument to inout parameter}}
546+
var z = &arg //expected-error {{'&' may only be used to pass an argument to inout parameter}}
547547

548548
takesExplicitInt(5) // expected-error {{cannot pass immutable value as inout argument: literals are not mutable}}
549549
}
@@ -701,8 +701,8 @@ func test() {
701701
let y = Foo()
702702

703703
// rdar://15708430
704-
(&x).method() // expected-error {{use of extraneous '&'}}
705-
(&x).mutatingMethod() // expected-error {{use of extraneous '&'}}
704+
(&x).method() // expected-error {{'&' may only be used to pass an argument to inout parameter}}
705+
(&x).mutatingMethod() // expected-error {{'&' may only be used to pass an argument to inout parameter}}
706706
}
707707

708708

@@ -832,20 +832,20 @@ public struct TestPropMethodOverloadGroup {
832832
// <rdar://problem/18496742> Passing ternary operator expression as inout crashes Swift compiler
833833
func inoutTests(_ arr: inout Int) {
834834
var x = 1, y = 2
835-
(true ? &x : &y) // expected-error {{use of extraneous '&'}}
836-
let a = (true ? &x : &y) // expected-error {{use of extraneous '&'}}
835+
(true ? &x : &y) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
836+
let a = (true ? &x : &y) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
837837

838-
inoutTests(true ? &x : &y) // expected-error {{use of extraneous '&'}}
838+
inoutTests(true ? &x : &y) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
839839

840-
&_ // expected-error {{use of extraneous '&'}}
840+
&_ // expected-error {{'&' may only be used to pass an argument to inout parameter}}
841841

842-
inoutTests((&x, 24).0) // expected-error {{use of extraneous '&'}}
842+
inoutTests((&x, 24).0) // expected-error {{'&' may only be used to pass an argument to inout parameter}}
843843

844-
inoutTests((&x)) // expected-error {{use of extraneous '&'}} {{15-16=(}} {{14-15=&}}
844+
inoutTests((&x)) // expected-error {{'&' may only be used to pass an argument to inout parameter}} {{15-16=(}} {{14-15=&}}
845845
inoutTests(&x)
846846

847847
// <rdar://problem/17489894> inout not rejected as operand to assignment operator
848-
&x += y // expected-error {{use of extraneous '&'}}
848+
&x += y // expected-error {{'&' may only be used to pass an argument to inout parameter}}
849849

850850
// <rdar://problem/23249098>
851851
func takeAny(_ x: Any) {}
@@ -861,7 +861,7 @@ func inoutTests(_ arr: inout Int) {
861861
// <rdar://problem/20802757> Compiler crash in default argument & inout expr
862862
var g20802757 = 2
863863
func r20802757(_ z: inout Int = &g20802757) { // expected-error {{cannot provide default value to inout parameter 'z'}}
864-
// expected-error@-1 {{use of extraneous '&'}}
864+
// expected-error@-1 {{'&' may only be used to pass an argument to inout parameter}}
865865
print(z)
866866
}
867867

0 commit comments

Comments
 (0)