Commit Graph

26 Commits

Author SHA1 Message Date
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
Carl Peto
ee57481d7c [AVR] AVR support - Initial PR
- Add simple support for the AVR architecture, as a supported conditional compilation value, and added to the default llvm targets to build.

(Later PRs will fix support for 16-bit pointers, which is broken in places, and any fixes needed to get the standard library to build.)

(Note: AVR as a target is expected to always be compiled with -enable-experimental-feature Embedded.)
2024-07-06 18:22:10 +01:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Kuba (Brecka) Mracek
d7e18cb554 Add 'none' to the list of available conditional compilation OS values, to support building for -none target triples (#65632) 2023-05-09 15:55:53 -07:00
Hamish Knight
628dcd6eb1 [Parse] Improve diagnostic for no platform condition argument
Drop the "only one" in the message in this case,
as that should only apply for too many args.
2021-09-24 16:38:30 +01:00
Hamish Knight
e3257fd0fa [Parse] Fix empty platform condition crash
Handle the empty argument case in `getSingleSubExp`,
otherwise we'd crash with an index out of bounds.

rdar://83017601
2021-09-24 16:38:29 +01:00
Rintaro Ishizaki
ce87bf7537 [Parse] Postfix '#if' expression
Implement postfix ifconfig expression which expands '#if' functionality
to postfix member reference expressions.

rdar://problem/51690082
2021-04-29 09:12:23 -07:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
3405691582
0d3b92dfb1 Swift Basic/Driver recognizes OpenBSD.
Add the platform conditional and set up other basics for the toolchain.

The ConditionalCompilation tests are updated to match, since otherwise
they seem to trip when building on non-OpenBSD platforms. The
Driver/linker test is updated to ensure lld is passed on this platform.
Note that OpenBSD calls "x86_64" as "amd64", so we use that name for the
architecture instead of trying to alias one to the other, as this makes
things simpler.
2020-02-27 17:14:22 -05:00
Devin Coughlin
8c5c5ec802 [Parse] Support macCatalyst conditional compilation
Add support for conditional compilation under macCatalyst

Developers can now detect whether they are compiling for macCatalyst at
compile time with:

  #if targetEnvironment(macCatalyst)
    // Code only compiled under macCatalyst.
  #end
2020-01-21 18:28:17 -08:00
Roopesh Chander
5e01b55a04 [Parser][QoI] Suppress fixits to underscored platform condition kinds
"_endian" and "_runtime" aren't officially supported platform condition
kinds, so don't suggest changing to one of those.
2019-08-21 19:52:03 +00:00
Roopesh Chander
34fec7f1d4 [Parser][QoI] Offer fixit for changing the platform condition kind
For example, for "#if os(simulator)", offer a fixit to change
"os" to "targetEnvironment", instead of offering to change "simulator".

Resolves SR-11037.
2019-08-21 19:51:47 +00:00
Owen Voorhees
901d947478 Improve diagnostic and add fixit to correct '#else if' to 'elseif'
Resolves SR-10581
2019-05-23 19:34:21 -07:00
Rintaro Ishizaki
4c6ece6fe0 [Parse] Don't invalidate compilation condition with invalid platform condition argument (#10221)
It's just a warning.
2017-06-14 15:09:24 +09:00
Joe Groff
9222960df5 Update ConditionalCompilation test. 2017-04-21 12:16:30 -07:00
Jacob Bandes-Storch
e1fd8aa6c7 [Parse] Fix crash in conditional compilation parsing (#7331) 2017-02-08 23:10:26 -08:00
Rintaro Ishizaki
b950f06f3e [Parse] Disallow unsupported condition expression in #if directive
In non-Swift3 mode.

Previously:

  #if FOO = false
  #elseif FOO ? false : true
  #endif

were silently accepted.
i.e. '= false' and '? false : true' were silently ignored.
2017-01-17 22:11:11 +09:00
Jacob Bandes-Storch
49f5251c73 [QoI] offer typo correction for platform conditionals 2017-01-12 09:07:53 -08:00
Robert Widmann
d2570cb964 Restore local type declarations list 2017-01-06 16:16:39 -07:00
practicalswift
9e60bdbffa [gardening] Fix typos. 2016-12-21 21:33:30 +01:00
Robert Widmann
9fd7b5a29c Validate the entire #if configuration
Being lazy here just means we don’t validate the entire if
configuration.  We need to be able to emit diagnostics even in
condition clauses with indeterminate expressions.
2016-12-19 02:32:47 -05:00
Robert Widmann
72beb9d80d Extract common code into StmtTransformer 2016-12-14 14:59:47 -05:00
Rintaro Ishizaki
ec53b6885f [Parse] Let #if diretives be parsed in parseBraceItems()
parseBraceItems() has specific logic for pasing conditional compilation blocks.
Withoutout that, decralations in the block cannot be propagated to outside.
For instance:

  FOO: #if true
  func foo() {}
  #endif
  foo() // error: use of unresolved identifier 'foo'
2016-12-06 22:28:53 +09:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Bryan Chan
bb3486df93 Add new _endian() platform condition check; valid values are "little" and "big". 2016-05-24 19:39:15 -04: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