Commit Graph

538 Commits

Author SHA1 Message Date
Rintaro Ishizaki
e7be78b84d [Parse] Skip type specifiers in middle of composition types
Like `P & inout P2`.
Don't bother to construct wrapped TypeRepr for them.
2017-11-30 15:59:35 +09:00
Graydon Hoare
94988a253e [Parse] Add suggestion to targetEnvironment diagnostic. 2017-11-28 15:55:12 -08:00
Graydon Hoare
d31bad45b8 [Parse] Add fixit for targetEnvironment(simulator) 2017-11-28 13:51:01 -08:00
Erik Eckstein
8033476b64 Function-level optimization attributes.
For now these are underscored attributes, i.e. compiler internal attributes:
@_optimize(speed)
@_optimize(size)
@_optimize(none)

Those attributes override the command-line specified optimization mode for a specific function.
The @_optimize(none) attribute is equivalent to the already existing @_semantics("optimize.sil.never") attribute
2017-11-14 11:25:02 -08:00
Huon Wilson
0236db7be1 [SIL] Witness methods store the conformance from which they come. 2017-11-01 11:33:26 -07:00
Slava Pestov
c25e41c34c AST: Fix a typo in a diagnostic 2017-10-24 20:45:49 -07:00
Graydon Hoare
bf42def404 [Diagnostics] s/may/must/ in 'may not have multiple' 2017-09-29 16:09:23 -04:00
Graydon Hoare
08bb212967 [Diagnostics] s/may/must/ in 'may not have bodies' 2017-09-29 16:09:23 -04:00
Graydon Hoare
c2ce848563 [Diagnostics] s/may/must/ in 'may not have a generic parameter list' 2017-09-29 16:09:23 -04:00
Graydon Hoare
0097adf4c0 [Diagnostics] s/may/must/ in 'may not also have a' 2017-09-29 16:09:23 -04:00
John McCall
ab3f77baf2 Make SILInstruction no longer a subclass of ValueBase and
introduce a common superclass, SILNode.

This is in preparation for allowing instructions to have multiple
results.  It is also a somewhat more elegant representation for
instructions that have zero results.  Instructions that are known
to have exactly one result inherit from a class, SingleValueInstruction,
that subclasses both ValueBase and SILInstruction.  Some care must be
taken when working with SILNode pointers and testing for equality;
please see the comment on SILNode for more information.

A number of SIL passes needed to be updated in order to handle this
new distinction between SIL values and SIL instructions.

Note that the SIL parser is now stricter about not trying to assign
a result value from an instruction (like 'return' or 'strong_retain')
that does not produce any.
2017-09-25 02:06:26 -04:00
Joe Groff
78d75428d6 SILGen: Lower key path subscript indexes.
And fill out SIL support for parsing, printing, and serializing key path
patterns with captured indexes.
2017-09-15 10:00:32 -07:00
Slava Pestov
9126d316d8 Parse: Remove parseTypeForInheritance()
We can just use parseType() everywhere instead. We already check
for non-identifier types in inheritance clauses elsewhere, and indeed
we have to anyway because an identifier type might resolve to a
type alias whose underlying type is a non-nominal type.

It doesn't look like this change made any diagnostics worse, but if
we find a case where it did, we could revert it.
2017-09-05 21:53:52 -07:00
Slava Pestov
3e2acb8ab0 Parse: Allow protocol compositions in all inheritance clauses
We allowed them for generic parameter inheritance clauses but
not anywhere else. While arguably this has stylistic benefits,
the restriction was not enforced consistently and was mostly a
result of implementation limitations.

Lift the restriction and fix things up where needed to make them
work. This brings us closer to allowing protocols to constrain
the 'Self' type to a subclass of a class by listing the class in
the protocol's inheritance clause, which was a feature from SE-0156,
but this doesn't quite work.

Fixes <https://bugs.swift.org/browse/SR-4678> and
<rdar://problem/31785092>.
2017-09-05 21:53:52 -07:00
Slava Pestov
19fed22872 Parse: Remove redundant diagnostic
We had two slightly different codepaths to diagnose ': class'
in an inheritance clause where it is not supported.

For generic parameters, we would fix the 'class' to 'AnyObject',
but for associated types we didn't do this. Perform the fix in
all cases where it makes sense and remove one of the two
diagnostics.
2017-09-05 21:53:52 -07:00
Jordan Rose
449cd98997 Excise "Accessibility" from the compiler (3/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

Rename AccessibilityAttr to AccessControlAttr and
SetterAccessibilityAttr to SetterAccessAttr, then track down the last
few uses of "accessibility" that don't have to do with
NSAccessibility. (I left the SourceKit XPC API alone because that's
supposed to be more stable.)
2017-08-28 13:27:59 -07:00
Slava Pestov
556d35d9b1 SIL: Record whether vtable entries are inherited or overridden
Consider a class hierarchy like the following:

class Base {
  func m1() {}
  func m2() {}
}

class Derived : Base {
  override func m2() {}
  func m3() {}
}

The SIL vtable for 'Derived' now records that the entry for m1
is inherited, the entry for m2 is an override, and the entry
for m3 is a new entry:

sil_vtable Derived {
  #Base.m1!1: (Base) -> () -> () : _T01a4BaseC2m1yyF [inherited]
  #Base.m2!1: (Base) -> () -> () : _T01a7DerivedC2m2yyF [override]
  #Derived.m3!1: (Derived) -> () -> () : _T01a7DerivedC2m3yyF
}

This additional information will allow IRGen to emit the vtable
for Derived resiliently, without referencing the symbol for
the inherited method m1() directly.
2017-08-14 19:50:34 -04:00
Rintaro Ishizaki
546aeb2336 [Parse] Remove Parser support for C-style for statement. 2017-08-04 23:27:15 +09:00
Rintaro Ishizaki
a2d3ff4deb [SE-0182][Lexer] Diagnose escaped newline at the end of the last line in multiline string 2017-07-26 21:18:58 +09:00
Robert Widmann
b77f2c147c Parse Shared
Add parser support for __shared and __owned as type attributes.  Also, extend parser diagnostics and tests to account for the new type attributes.
2017-07-23 21:47:25 -07:00
Huon Wilson
2e952d2686 Merge pull request #10908 from huonw/swift3-is-behind-us-now
Upgrade some deprecation warnings from Swift 3 to errors in Swift 4.
2017-07-12 16:25:46 -07:00
Huon Wilson
55e1aa2a9f [Parse] Upgrade @noescape/@autoclosure(escaping) warnings to Swift 4 errors.
Part of rdar://problem/28961650 .
2017-07-12 13:26:09 -07:00
Huon Wilson
74ea3c12d4 [Parse] Upgrade unlabeled_parameter_following_variadic_parameter to Swift 4 error.
Part of rdar://problem/28961650 .
2017-07-12 13:17:40 -07:00
Huon Wilson
04fa7ce29d [Parse] Upgrade protocol<...> warnings to Swift 4 errors.
Part of rdar://problem/28961650 .
2017-07-12 13:17:40 -07:00
Huon Wilson
09f45c8f2b [Parse] Upgrade deprecated_operator_body* to Swift 4 errors.
Part of rdar://problem/28961650 .
2017-07-12 13:17:40 -07:00
Huon Wilson
e2d01f5cce [Parse] Upgrade operator_static_in_protocol to Swift 4 error.
Part of rdar://problem/28961650 .
2017-07-12 13:17:40 -07:00
David Rönnqvist
57731ebc09 [QoI] [Parse] Improve error message when parsing floating point exponent
Update error messages to mention the invalid character.
Improve the diagnostic of floating point exponents.

Add tests for error messages when parsing floating point exponents.
Update existing tests for new error messages.
2017-07-08 13:32:34 +02:00
David Rönnqvist
a615d9ede3 [QoI] Improve error message when parsing integer literal
Rephrased error message to indicate which character is unexpected.
Provide error message variations when parsing binary, octal, decimal (default), and hexadecimal integer literals.
Look for unexpected digits in binary and octal integer literals.
Look for unexpected letters in hex integer literals.

Resolves: SR-5236 rdar://problem/32858684
2017-07-06 19:59:09 +02:00
Robert Widmann
43f29399f3 Remove an old diagnostic for 'var' in param position
Using the attribute in this position is a relic from the Swift 2
days, and fixing it required letting invalid code fall through to
Sema instead of being diagnosed in Parse proper.  Treat 'var'
in this position like 'let' by simply offering to remove it
instead of extracting it into a separate variable.
2017-06-29 13:35:59 -07:00
George Karpenkov
43d38d32fe Fixing grammar in error messages. (#10505)
Fixing grammar in error messages:

"is obsoleted" is only used in context of "X is obsoleted by Y".
When used as a rough synonym of "deprecated" the program grammar is "is
obsolete".
2017-06-26 13:33:26 -07:00
Huon Wilson
61606a6616 [Parse] Provide better diagnostics for func 1() {}.
It is apparently a common mistake for beginners to start the names of functions
etc. with numbers, and before this patch the diagnostic wasn't specific about
the problem. It seems likely that most instances of `func 1(...` will be
mistakes in this vein, so this patch specifically diagnoses that case, and also
parses the number as the identifier to avoid follow on errors about top-level
closures (from the {}) and other invalid syntax.

Fixes rdar://problem/32316666 .
2017-06-20 16:49:50 -07:00
Jordan Rose
5c1967397b Update and re-enable the diagnostics for unstable runtime names.
This time, the warnings only fire when the class in question directly
conforms to NSCoding. This avoids warning on cases where the user has
subclassed something like, oh, UIViewController, and has no intention
of writing it to a persistent file.

This also removes the warning for generic classes that conform to
NSCoding, for simplicity's sake. That means
'@NSKeyedArchiverEncodeNonGenericSubclassesOnly' is also being
removed.

Actually archiving a class with an unstable mangled name is still
considered problematic, but the compiler shouldn't emit diagnostics
unless it can be sure they are relevant.

rdar://problem/32314195
2017-06-05 17:32:26 -07:00
Jordan Rose
f0aca936c7 Allow '@objc(RuntimeName)' on classes with generic ancestry.
This is accomplished by recognizing this specific situation and
replacing the 'objc' attribute with a hidden '_objcRuntimeName'
attribute. This /only/ applies to classes that are themselves
non-generic (including any enclosing generic context) but that have
generic ancestry, and thus cannot be exposed directly to Objective-C.

This commit also eliminates '@NSKeyedArchiverClassName'. It was
decided that the distinction between '@NSKeyedArchiverClassName' and
'@objc' was too subtle to be worth explaining to developers, and that
any case where you'd use '@NSKeyedArchiverClassName' was already a
place where the ObjC name wasn't visible at compile time.

This commit does not update diagnostics to reflect this change; we're
going to change them anyway.

rdar://problem/32414557
2017-06-05 17:32:25 -07:00
practicalswift
4d216151e1 [gardening] Remove unused diagnostic 2017-05-16 23:22:59 +02:00
ematejska
6d8511218f Merge pull request #9636 from ematejska/update_where_clause_warning_to_error
Update where clause warning to error for Swift 4
2017-05-15 21:55:55 -07:00
Rintaro Ishizaki
04f31a76c0 Merge pull request #7955 from rintaro/parse-ifconfig-validate
[Parse] Separate compilation condition validation and evaluation
2017-05-16 12:06:31 +09:00
Ewa Matejska
fa6e207f62 Updating to have stronger working for warning and review feedback 2017-05-15 18:43:10 -07:00
Ewa Matejska
24a9bea5d6 Adding compatiblity test, updating warning. 2017-05-15 16:26:32 -07:00
Ewa Matejska
4553d5ea67 Making the where_inside_brackets warning into an Error for > Swift 3. 2017-05-15 15:12:14 -07:00
swift-ci
6f0ddedfaf Merge pull request #9219 from xedin/closure-arg-diag 2017-05-08 23:58:36 -07:00
Pavel Yaskevich
ddaccf88bb [QoI] Properly diagnose closure parameter distructuring after SE-0110
Swift 3 supported limited argument destructuring when it comes to
declaring (trailing) closures. Such behavior has been changed by
SE-0110. This patch aims to provide better error message as well
as fix-it (if structure of the expected and actual arguments matches)
to make the migration easier and disambiguate some of the common
mistakes.

Resolves: SR-4738, SR-4745, rdar://problem/31892961.
2017-05-08 23:04:37 -07:00
Brent Royal-Gordon
1d70565d55 Better diagnostics for multi-line string literals (#9148)
[Parse] Improve multi-line string literal errors

Adds descriptive errors and fix-its for multi-line string literal indentation and newline errors.
2017-05-08 13:24:31 -07:00
Robin Kunde
6d63d90e0e SR-331: Diagnostic notes and fixits for unicode confusables (#9070) 2017-05-06 17:40:35 -04:00
practicalswift
f7a16f5149 [gardening] Remove unused diagnostic 2017-05-04 15:22:07 +02:00
Huon Wilson
4fc27a1f3e Merge pull request #9150 from huonw/keypath-syntax
Implement \ syntax for Swift key paths.
2017-05-03 06:22:47 +10:00
Huon Wilson
07c5ab8fb2 Implement \ syntax for Swift key paths.
This introduces a few unfortunate things because the syntax is awkward.
In particular, the period and following token in \.[a], \.? and \.! are
token sequences that don't appear anywhere else in Swift, and so need
special handling. This is somewhat compounded by \foo.bar.baz possibly
being \(foo).bar.baz or \(foo.bar).baz (parens around the type), and,
furthermore, needing to distinguish \Foo?.bar from \Foo.?bar.

rdar://problem/31724243
2017-05-01 16:06:15 -07:00
Robert Widmann
370b08a927 Revise diagnostic message for availability fixit 2017-04-30 21:48:06 -04:00
David Rönnqvist
f45196d022 [SR-4231] Add diagnostic (& fix-it) for mixed syntax availability attribute (#9122)
* [Parse] Add diagnostic for mixed syntax availability attribute

When parsing a list of availablity specifications in the shorthand syntax, check to see that the next specification is also in shorthand syntax. If the next specification looks like an explicit “deprecated” (or similad) attribute, then emit a specific diagnostic about it to help the developer understand the problem.

https://bugs.swift.org/browse/SR-4231

* [Parse] Add fix-it for single mixed availability syntax

For the scenario that’s described in SR-4231, when there is one shorthard syntax followed by ‘deprecated’ (or similar), then we can guess that the intention was to treat the shorthand as ‘introduced’ so that the two of them work together.

This guess is only made if there is one platform version constrain, that is followed by ‘deprecated’, ‘renamed’, etc. but not ‘introduced’.

https://bugs.swift.org/browse/SR-4231

* Automatic formatting using git-clang-format

* Fix typos in test code and language in comment

Also, consistently names test functions as “deprecated” and "introduced"

* [Parse] Add note to explain the mixed availability syntax fix-it insertion

This change also moves the fix-it from the error to the note.
2017-04-30 19:39:38 -04:00
John Holdsworth
fea17f22aa [Parse] Add support for multiline strings inside interpolations
Adds support for multiline string literals to appear inside of string interpolations. Tests added.
2017-04-27 19:02:23 -07:00
practicalswift
ab5aaeb359 Merge pull request #9001 from practicalswift/gardening-20170425
[gardening] Unused variables. Unused diagnostics. Namespace comments. Typos.
2017-04-26 09:28:24 +02:00