1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
// RUN: %target-typecheck-verify-swift
#if swift(>=1.0)
let w = 1
#else
// This shouldn't emit any diagnostics.
asdf asdf asdf asdf
#endif
#if swift(<1.2)
#endif
#if swift(<4.2)
let a = 1
#else
let a = 2
#endif
#if swift(<1.0)
// This shouldn't emit any diagnostics.
asdf asdf asdf asdf
#endif
#if swift(>=1.2)
#if os(iOS)
let z = 1
#else
let z = 1
#endif
#else
// This shouldn't emit any diagnostics.
asdf asdf asdf asdf
#if os(iOS)
// This shouldn't emit any diagnostics.
asdf asdf asdf asdf
#else
// This shouldn't emit any diagnostics.
asdf asdf asdf asdf
#endif
// This shouldn't emit any diagnostics.
asdf asdf asdf asdf
#endif
#if !swift(>=1.0)
// This shouldn't emit any diagnostics.
%#^*&
#endif
#if !swift(<1000.0)
// This shouldn't emit any diagnostics.
%#^*&
#endif
#if swift(">=7.1") // expected-error@:11 {{unexpected platform condition argument: expected a unary comparison '>=' or '<'; for example, '>=2.2' or '<2.2'}}
#endif
#if swift("<7.1") // expected-error@:11 {{unexpected platform condition argument: expected a unary comparison '>=' or '<'; for example, '>=2.2' or '<2.2'}}
#endif
#if swift(">=2n.2") // expected-error@:11 {{unexpected platform condition argument: expected a unary comparison '>=' or '<'; for example, '>=2.2' or '<2.2'}}
#endif
#if swift("") // expected-error@:11 {{unexpected platform condition argument: expected a unary comparison '>=' or '<'; for example, '>=2.2' or '<2.2'}}
#endif
#if swift(>=2.2.1)
_ = 2.2.1 // expected-error {{expected named member of numeric literal}}
#endif
class C {
#if swift(>=2.2.1)
let val = 2.2.1 // expected-error {{expected named member of numeric literal}}
#endif
}
#if swift(>=2.0, *) // expected-error@:11 {{expected only one unlabeled argument to platform condition}}
#endif
#if swift(>=, 2.0) // expected-error@:11 {{expected only one unlabeled argument to platform condition}}
#endif
#if swift(version: >=2.0) // expected-error@:11 {{expected only one unlabeled argument to platform condition}}
#endif
protocol P {
#if swift(>=2.2)
associatedtype Index
#else
// There should be no warning here.
typealias Index
// There should be no error here.
adsf asdf asdf
%#^*&
func foo(sdfsdfdsf adsf adsf asdf adsf adsf)
#endif
}
#if swift(>=2.2)
func foo() {}
#else
// There should be no error here.
func foo(sdfsdfdsf adsf adsf asdf adsf adsf)
#endif
struct S {
#if swift(>=2.2)
let x: Int
#else
// There should be no error here.
let x: @#$()%&*)@#$(%&*
#endif
}
#if swift(>=2.2)
var zzz = "zzz"
#else
// There should be no error here.
var zzz = zzz
#endif
|