Files
swift-mirror/test/attr/attr_semantics.swift
Michael Gottesman fe257d58a7 [semantics] Add support for annotating VarDecls with @_semantics.
This is just for prototyping purposes. I also had to loosen a small restriction
where semantics functions were not allowed in local contexts. There really is no
reason to enforce this and I think since it came in the first commit that
introduced semanitcs it was most likely NadavR just being conservative and
careful.
2019-11-05 17:31:58 -08:00

66 lines
1.3 KiB
Swift

// RUN: %target-typecheck-verify-swift
@_semantics("foo")
@_semantics("bar")
func duplicatesemantics() {}
func func_with_nested_semantics_1() {
@_semantics("exit")
func exit(_ code : UInt32) -> Void
exit(0)
}
// Test parser recovery by having something that
// should parse fine.
func somethingThatShouldParseFine() {}
func func_with_nested_semantics_2() {
@_semantics("exit")
func exit(_ code : UInt32) -> Void
exit(0)
}
@_semantics("struct")
struct StructWithSemantics {}
@_semantics("class")
class ClassWithSemantics {}
@_semantics("enum")
enum EnumWithSemantics {}
@_semantics("struct1")
@_semantics("struct2")
struct StructWithDuplicateSemantics {}
@_semantics("globalVar1")
@_semantics("globalVar2")
var globalVarWithSemantics : Int = 5
@_semantics("globalLet1")
@_semantics("globalLet2")
let globalLetWithSemantics : Int = 5
func varDeclLocalVars() {
@_semantics("localVar1")
@_semantics("localVar2")
var localVarWithSemantics : Int = 5
localVarWithSemantics = 6
let _ = localVarWithSemantics
@_semantics("localLet1")
@_semantics("localLet2")
let localLetWithSemantics : Int = 5
let _ = localLetWithSemantics
}
struct IVarTest {
@_semantics("localVar1")
@_semantics("localVar2")
var localVarWithSemantics : Int = 5
@_semantics("localLet1")
@_semantics("localLet2")
let localLetWithSemantics : Int = 5
}