Commit Graph

47 Commits

Author SHA1 Message Date
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00
Jordan Rose
7954be4d87 [test] Move BuildConfigurations/ to Parse/ConditionalCompilation/.
Also move a Parse test that's really about conditional compilation
directives into the new folder.
2016-02-12 11:10:32 -08:00
Jordan Rose
6272941c5c Rename "build configurations" to "conditional compilation blocks".
...because "build configuration" is already the name of an Xcode feature.

- '#if' et al are "conditional compilation directives".
- The condition is a "conditional compilation expression", or just
  "condition" if it's obvious.
- The predicates are "platform conditions" (including 'swift(>=...)')
- The options set with -D are "custom conditional compilation flags".
  (Thanks, Kevin!)

I left "IfConfigDecl" as is, as well as SourceKit's various "BuildConfig"
settings because some of them are part of the SourceKit request format.
We can change these in follow-up commits, or not.

rdar://problem/19812930
2016-02-12 11:09:26 -08:00
David Farler
c32fb8e7b9 SE-0020: Swift Language Version Build Configuration
Introduce a new "swift" build configuration that guards declarations
and statements with a language version - if the current language version
of the compiler is at least that version, the block will parse as normal.
For inactive blocks, the code will not be parsed an no diagnostics will
be emitted there.

Example:

    #if swift(>=2.2)
      print("Active")
    #else
      this code will not parse or emit diagnostics
    #endif

https://github.com/apple/swift-evolution/blob/master/proposals/0020-if-swift-version.md
rdar://problem/19823607
2016-01-21 16:31:19 -08:00
Anton Blanchard
b1827d8a8f Add powerpc64le Linux support
This patch adds powerpc64le Linux support. While the patch also adds
the matching powerpc64 bits, there are endian issues that need to be
sorted out.

The PowerPC LLVM changes for the swift ABI (eg returning three element
non-homogeneous aggregates) are still in the works, but a simple LLVM
fix to allow those aggregates results in swift passing all but 8
test cases.
2016-01-15 06:48:31 +00:00
Ted Kremenek
b03617efd0 Remove bogus 'expected-error'. 2016-01-05 22:05:22 -08:00
practicalswift
e0eba97b98 Fix typos. 2016-01-06 00:48:22 +01:00
Daniel Duan
239c6629e9 Remove trailing semi-colons in .swift files 2015-12-20 21:12:11 -08:00
Landon Fuller
c671947615 Apply patch provided by gribozavr; swift -target requires a proper triple. 2015-12-04 18:39:20 -07:00
Landon Fuller
1acab5ab01 Add a target configuration option test for FreeBSD. 2015-12-04 14:26:29 -07:00
Dmitri Gribenko
4324e7c903 Remove conditional compilation of tvOS 2015-12-01 14:43:45 -07:00
David Farler
7fceb124ba Look for EOF in addition to whitespace to lex the #endif token
In addition to just a whitespace char, also look ahead to a null
character to lex the #endif token.  This allows the token to be formed
when at the end of a file.

Fix endif-on-end-of-file.swift test file to not end in whitespace.

rdar://problem/21692337

Swift SVN r32224
2015-09-25 07:28:32 +00:00
David Farler
69b6763797 Emit a warning when using unknown arch/os build configurations
'arch' and 'os' build configurations with valid identifiers as
arguments, but which are unknown to the compiler, will cause the
compiler to silently skip over that code as it has an inactive clause.
Emit a diagnostic, but not an error so as not to inadvertantly break
code that may be in a compiler without knowledge of a particular
operating system or architecture.

rdar://problem/22052176

Swift SVN r32219
2015-09-25 05:24:34 +00:00
David Farler
2a0f027317 Review changes for _compiler_version
A couple of small tweaks to _compiler_version based on review comments:
- Fix &&/|| rejection to work with _compiler_version on either side of the
expression. Also add some test cases around this.
- Use clang/LLVM facilities for isdigit and atoi.
- Assert if parsing an invalid version string and there is no diagnostic
engine.
- Clean up some crumbs in the CMake configs.

rdar://problem/22730282

Swift SVN r32212
2015-09-24 22:47:01 +00:00
David Farler
9d373d0fc7 Add _compiler_version build configuration
This configuration clause will suppress lex diagnostics and skip parsing
altogether if the code under the clause isn't active - the compiler must
have a repository version greater than or equal to the version given to
_compiler_version.

This option is only meant to be used sparingly and not to track the
Swift *language* version.

Example, if using a compiler versioned 700.0.28:

  #if _compiler_version("700.0.23")
    print("This code will compile for versions 700.0.23 and later.")
  #else
    This + code + will + not + be + parsed
  #endif

Included are new diagnostics for checking that the version is formatted
correctly and isn't empty.

New tests:
- Compiler version comparison unit tests
- Build configuration diagnostics
- Skipping parsing of code under inactive clauses

rdar://problem/22730282

Swift SVN r32195
2015-09-24 02:14:47 +00:00
Dmitri Hrybenko
3f7d64c532 Diagnose invalid arguments for '#if _runtime()'
rdar://problem/20117677

Swift SVN r31336
2015-08-19 16:55:39 +00:00
Chris Lattner
ada5487153 add fixit tests to random other tests.
Swift SVN r31006
2015-08-04 20:35:36 +00:00
Dmitri Hrybenko
f3eba9a51b Remove a test change that I forgot to revert before committing
Swift SVN r28757
2015-05-19 05:57:26 +00:00
Dmitri Hrybenko
ea17483633 Add CMake options and #ifs to hide tvOS
Swift SVN r28752
2015-05-19 05:15:52 +00:00
Chris Lattner
e4b6afb9ae Start moving the testsuite to the "_ = foo()" idiom for evaluating an
expression but ignoring its value.  This is the right canonical way to do
this.  NFC, just testsuite changes.



Swift SVN r28638
2015-05-15 20:15:54 +00:00
Chris Lattner
acf5a426bb as a tiny QoI improvement, parse "#if 0" and recover as if the user
wrote "#if false" while producing an error + fixit.


Swift SVN r28411
2015-05-11 06:07:44 +00:00
Chris Lattner
4366da9250 more testcase updates for upcoming diagnostics change.
Swift SVN r28409
2015-05-11 06:05:00 +00:00
Dmitri Hrybenko
f46f16ae82 stdlib: implement new print() API
rdar://20775683

Swift SVN r28309
2015-05-08 01:37:59 +00:00
Chris Lattner
f71a329afd fix <rdar://problem/17569958> #endif not parsed correctly when occurs as last line in file
Swift SVN r27753
2015-04-26 05:32:04 +00:00
David Farler
1d9b0af93b os(iOS) shouldn't imply os(tvOS)
rdar://problem/20213434

Swift SVN r26285
2015-03-18 23:22:27 +00:00
David Farler
544ef4002d Merge tvOS and watchOS Support
- Add frontend and standard library build support for tvOS.
- Add frontend support for watchOS.

watchOS standard library builds are still disabled during SDK bring-up.

To build for TVOS, specify --tvos to build-script.
To build for watchOS, specify --watchos to build-script (not yet supported).

This patch does not include turning on full tests for TVOS or watchOS, and
will be included in a follow-up patch.

Swift SVN r26278
2015-03-18 21:35:07 +00:00
Denis Vnukov
aa36639210 [rdar://19605880], minor: review feedback incorporated
Swift SVN r24800
2015-01-28 18:54:12 +00:00
Denis Vnukov
995e4429b8 Fix for rdar://problem/19605880, Fuzzing Swift: crash in Verifier::walkToStmtPost(...): invalid IfConfigStmt end location
Proper braces locations for protocol in erroneous case.



Swift SVN r24799
2015-01-28 18:32:49 +00:00
Denis Vnukov
6776cb2e95 Fix for rdar://problem/19582877, Fuzzing Swift: Parser::parseTopLevel() crashes in swift::verify(...)
Brace statement created for wrapping IfConfig inside TopLevelCodeDecl does not have 
closing brace, so we should use the previous token’s location as right brace location.



Swift SVN r24797
2015-01-28 17:48:36 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Graham Batty
83f27a8af7 Revert "Mark tests that don't pass on linux as XFAIL."
This reverts commit 2711ca86de7bf6a7885ccea24219a48a590b1e95.

Swift SVN r23577
2014-11-24 17:42:13 +00:00
Graham Batty
198402dcfe Mark tests that don't pass on linux as XFAIL.
Swift SVN r23573
2014-11-24 17:40:37 +00:00
Graham Batty
63a429f16e Changes to code generation to support non-objc targets
Swift SVN r23118
2014-11-05 18:05:55 +00:00
Denis Vnukov
448822b1c4 Fixed an issue in IfConfigStmt parsing leading to source ranges verification assertions (rdar://problem/18251200).
The change also includes replacing BraceStmt* reference in IfConfigStmtClause structure with a simple list of clause elements.




Swift SVN r22868
2014-10-21 22:48:20 +00:00
Graham Batty
7676c8240d Add compile time config flag for detecting objc-interop.
Swift SVN r22605
2014-10-08 17:09:34 +00:00
Jordan Rose
0481b87ba5 Move target configuration setup into CompilerInvocation.
Without this, clients that don't use a CompilerInstance (like LLDB) won't
have target configuration options available.

Also, move minimum OS checking into the driver. This makes sure the check
happens early (and only once), and in general fits the philosophy of
allowing the frontend to use configurations that might be banned for users.

<rdar://problem/17688913>

Swift SVN r20701
2014-07-29 21:48:59 +00:00
Jordan Rose
d6f0a524b0 Fatal errors during -verify should always be treated as errors.
To disable this behavior, use the -show-diagnostics-after-fatal option.

Swift SVN r19483
2014-07-02 21:32:49 +00:00
Ted Kremenek
d075f06573 Require a minimum deployment target of iOS 7 or OSX 10.9
Implements <rdar://problem/17532113>

Swift SVN r19451
2014-07-02 06:23:38 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Joe Pamer
a17cec6cb2 Some test and diagnostic cleanup:
- Mine conjunction constraints for constraint failure data. (rdar://problem/16833763)
- Rather than crash, add a diagnostic to signify a missing user constraint. (rdar://problem/16747055) I don't have a deterministic repro for this to include as a test, but users hit it from time to time, I'd like to address this issue holistically, and we're hoping that the new diagnostic will help us collect isolated repros.
- As promised, remove the temporary "compiler_submit_version" build configuration predicate in time for WWDC. (rdar://problem/16380797)

Swift SVN r17705
2014-05-08 18:46:08 +00:00
Joe Pamer
7b771affd9 Add limited build configuration support for testing against compiler submit versions. (rdar://problem/16337966)
This is meant to be utilized for a narrow set of scenarios specific to dogfooding our pre-1.0 compiler, so please do not take any dependencies on this.  In fact, I'll be removing this in the next milestone.  (See rdar://problem/16380797.)

Also included - improve error recovery when parsing broken build configuration clauses.

Swift SVN r15694
2014-03-31 20:34:02 +00:00
Joe Pamer
a54848d470 Fix regression when parsing #if clauses without a configuration expression. (rdar://problem/16376781)
Swift SVN r15539
2014-03-27 00:08:50 +00:00
Joe Pamer
3a0363b405 When parsing build configuration blocks, pass the actual BraceItemListKind through, rather than signify whether something is "top level" or not. This allows proper codegen for overloaded operators at the module top-level.
Swift SVN r14611
2014-03-03 21:48:36 +00:00
Joe Pamer
806ba74ac5 Add test for error recovery improvements in r14369.
Swift SVN r14476
2014-02-27 21:19:04 +00:00
Joe Pamer
cc91b28076 If a target configuration invocation is followed by an indented identifier on a new line, the target invocation expression may be parsed as having a trailing closure. Add a new StructureMarkerKind so we can prevent this from happening.
Swift SVN r14368
2014-02-26 02:06:29 +00:00
Joe Pamer
b46d20240d Update build configuration tests to be independent of their runtime platform.
Also, add more tests for the "os" and "arch" target configurations, to exercise likely
build configurations for iOS and the iOS simulator.

Swift SVN r14307
2014-02-24 18:16:50 +00:00
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