Files
swift-mirror/test/BuildConfigurations/basicDeclarations.swift
Joe Pamer f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00

66 lines
781 B
Swift

// RUN: %swift -parse %s -verify -D FOO -D BAR
// REQUIRES: X86
class A {}
#if FOO
typealias A1 = A;
#endif
var a: A = A()
var a1: A1 = A1() // should not result in an error
#if FOO
class C {}
#endif
var c = C() // should not result in an error
class D {
#if FOO
var x: Int;
#endif
init() {
#if !BAR
x = "BAR"; // should not result in an error
#else
x = 1;
#endif
}
}
var d = D()
#if !FOO
func f1() -> Bool {
return true
}
#else
func f1() -> Int {
#if BAR
return 1
#else
return "1" // should not result in an error
#endif
}
#endif
var i: Int = f1()
protocol P1 {
#if FOO
func fFOO() -> Int;
#endif
#if !BAR
func fNotBAR() -> Int;
#else
func fBAR() -> Int;
#endif
}
class P : P1 {
func fFOO() -> Int { return 0; }
func fBAR() -> Int { return 0; }
}