You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
C++ parser: support borrowing and consuming modifiers.
And adjust contextual parameter modifier parsing in general to be more
properly contextual, so we don't have to reserve `__shared` or `__owned`,
or their successor spellings, as argument labels anymore.
Copy file name to clipboardExpand all lines: test/Parse/invalid.swift
+4-14Lines changed: 4 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,6 @@ func test2(inout let x : Int) {} // expected-warning {{'let' in this position i
7
7
// expected-error @-1 {{'inout' before a parameter name is not allowed, place it before the parameter type instead}} {{12-17=}} {{26-26=inout }}
8
8
func test3(f :(inout_ x : Int)->Void){} // expected-error {{'inout' before a parameter name is not allowed, place it before the parameter type instead}}
9
9
10
-
func test1s(__shared var x :Int){} // expected-warning {{'var' in this position is interpreted as an argument label}} {{22-25=`var`}}
11
-
// expected-error @-1 {{'__shared' before a parameter name is not allowed, place it before the parameter type instead}} {{13-21=}} {{30-30=__shared }}
12
-
func test2s(__shared let x :Int){} // expected-warning {{'let' in this position is interpreted as an argument label}} {{22-25=`let`}}
13
-
// expected-error @-1 {{'__shared' before a parameter name is not allowed, place it before the parameter type instead}} {{13-21=}} {{30-30=__shared }}
14
-
15
-
func test1o(__owned var x :Int){} // expected-warning {{'var' in this position is interpreted as an argument label}} {{21-24=`var`}}
16
-
// expected-error @-1 {{'__owned' before a parameter name is not allowed, place it before the parameter type instead}} {{13-20=}}
17
-
func test2o(__owned let x :Int){} // expected-warning {{'let' in this position is interpreted as an argument label}} {{21-24=`let`}}
18
-
// expected-error @-1 {{'__owned' before a parameter name is not allowed, place it before the parameter type instead}} {{13-20=}}
19
-
20
10
func test3(){
21
11
undeclared_func( // expected-error {{cannot find 'undeclared_func' in scope}}
22
12
} // expected-error {{expected expression in list of expressions}}
@@ -94,15 +84,15 @@ do {
94
84
// https://github.com/apple/swift/issues/43591
95
85
// Two inout crash compiler
96
86
97
-
func f1_43591(a :inoutinoutInt){} // expected-error {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{19-25=}}
87
+
func f1_43591(a :inoutinoutInt){} // expected-error {{parameter may have at most one of the 'inout', 'borrowing', or 'consuming' specifiers}} {{19-25=}}
98
88
func f2_43591(inout inout b:Int){} // expected-error {{inout' before a parameter name is not allowed, place it before the parameter type instead}} {{15-20=}} {{30-30=inout }}
99
-
// expected-error@-1 {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{21-27=}}
89
+
// expected-error@-1 {{parameter may have at most one of the 'inout', 'borrowing', or 'consuming' specifiers}} {{21-27=}}
100
90
func f3_43591(let let a:Int){} // expected-warning {{'let' in this position is interpreted as an argument label}} {{15-18=`let`}}
// expected-error @-2 {{expected ':' following argument label and parameter name}}
103
93
// expected-warning @-3 {{extraneous duplicate parameter name; 'let' already has an argument label}} {{15-19=}}
104
-
func f4_43591(inout x:inoutString){} // expected-error {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{15-20=}}
105
-
func f5_43591(inout i:inoutInt){} // expected-error {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{15-20=}}
94
+
func f4_43591(inout x:inoutString){} // expected-error {{parameter may have at most one of the 'inout', 'borrowing', or 'consuming' specifiers}}
95
+
func f5_43591(inout i:inoutInt){} // expected-error {{parameter may have at most one of the 'inout', 'borrowing', or 'consuming' specifiers}} {{15-20=}}
106
96
107
97
funcrepeat(){}
108
98
// expected-error @-1 {{keyword 'repeat' cannot be used as an identifier here}}
Copy file name to clipboardExpand all lines: test/decl/func/functions.swift
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -129,7 +129,7 @@ func rdar16786220(inout let c: Int) -> () { // expected-warning {{'let' in this
129
129
c =42
130
130
}
131
131
132
-
func multipleSpecifiers(a:inout__owned Int){} // expected-error {{parameter must not have multiple '__owned', 'inout', or '__shared' specifiers}} {{28-34=}}
132
+
func multipleSpecifiers(a:inout__owned Int){} // expected-error {{parameter may have at most one of the 'inout', 'borrowing', or 'consuming' specifiers}} {{28-34=}}
133
133
134
134
// <rdar://problem/17763388> ambiguous operator emits same candidate multiple times
0 commit comments