Skip to content

Commit b069dbf

Browse files
committed
Add unsafe expression syntax under an experimental feature flag unsafeExpression
1 parent 37fa0c8 commit b069dbf

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CodeGeneration/Sources/SyntaxSupport/ExperimentalFeatures.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public enum ExperimentalFeature: String, CaseIterable {
2121
case coroutineAccessors
2222
case valueGenerics
2323
case abiAttribute
24+
case unsafeExpression
2425

2526
/// The name of the feature as it is written in the compiler's `Features.def` file.
2627
public var featureName: String {
@@ -41,6 +42,8 @@ public enum ExperimentalFeature: String, CaseIterable {
4142
return "ValueGenerics"
4243
case .abiAttribute:
4344
return "ABIAttribute"
45+
case .unsafeExpression:
46+
return "WarnUnsafe"
4447
}
4548
}
4649

@@ -63,6 +66,8 @@ public enum ExperimentalFeature: String, CaseIterable {
6366
return "value generics"
6467
case .abiAttribute:
6568
return "@abi attribute"
69+
case .unsafeExpression:
70+
return "'unsafe' expression"
6671
}
6772
}
6873

CodeGeneration/Sources/SyntaxSupport/ExprNodes.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,23 @@ public let EXPR_NODES: [Node] = [
180180
]
181181
),
182182

183+
Node(
184+
kind: .unsafeExpr,
185+
base: .expr,
186+
experimentalFeature: .unsafeExpression,
187+
nameForDiagnostics: "'unsafe' expression",
188+
children: [
189+
Child(
190+
name: "unsafeKeyword",
191+
kind: .token(choices: [.keyword(.unsafe)])
192+
),
193+
Child(
194+
name: "expression",
195+
kind: .node(kind: .expr)
196+
),
197+
]
198+
),
199+
183200
Node(
184201
kind: .binaryOperatorExpr,
185202
base: .expr,

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
299299
case unresolvedAsExpr
300300
case unresolvedIsExpr
301301
case unresolvedTernaryExpr
302+
case unsafeExpr
302303
case valueBindingPattern
303304
case variableDecl
304305
case versionComponent

0 commit comments

Comments
 (0)