Files
swift-mirror/test/Parse/ConditionalCompilation/language_version.swift
Doug Gregor e4cf74abfa Update expected diagnostics to match what SwiftIfConfig produces
For the most part, the differences between the diagnostics introduced
by the C++ implementation and the new SwiftIfConfig implementation are
cosmetic, so these are only wording changes.

The one major difference is that we've dropped the warnings about
potential typos in os/arch checks. For example, if one writes:

    #if os(bisionos)
    // ...
    #endif

The C++ implementation will produce a warning "unknown operating system
for build configuration 'os'" with a note asking "did you mean
'visionOS'"? These warnings rely on a static list of known operating
systems and architectures, which is somewhat unfortunate: the whole
point of these checks is that the Swift you're dealing with might not
have support for those operating systems/architectures, so while these
warnings can be helpful in a few cases, they also cause false
positives when porting. Therefore, I chose not to bring them forward.
2024-08-24 21:31:41 -07:00

123 lines
2.4 KiB
Swift

// 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@:5 {{'swift' requires a single unlabeled argument for the version comparison}}
#endif
#if swift("<7.1") // expected-error@:5 {{'swift' requires a single unlabeled argument for the version comparison}}
#endif
#if swift(">=2n.2") // expected-error@:5 {{'swift' requires a single unlabeled argument for the version comparison}}
#endif
#if swift("") // expected-error@:5 {{'swift' requires a single unlabeled argument for the version comparison}}
#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@:5 {{'swift' requires a single unlabeled argument for the version comparison}}
#endif
#if swift(>=, 2.0) // expected-error@:5 {{'swift' requires a single unlabeled argument for the version comparison}}
#endif
#if swift(version: >=2.0) // expected-error@:5 {{'swift' requires a single unlabeled argument for the version comparison}}
#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