Merge pull request #6999 from akyrtzi/index-kinds-test-subclass
[index] Mark unit test methods if the class subclasses XCTestCase.
diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def
index e9de472..e72dac1 100644
--- a/include/swift/AST/DiagnosticsSema.def
+++ b/include/swift/AST/DiagnosticsSema.def
@@ -923,12 +923,14 @@
//------------------------------------------------------------------------------
ERROR(var_type_not_materializable,none,
- "type %0 of variable is not materializable", (Type))
+ "variable has type %0 which includes nested inout parameters",
+ (Type))
ERROR(param_type_non_materializable_tuple,none,
"named parameter has type %0 which includes nested inout parameters",
(Type))
ERROR(enum_element_not_materializable,none,
- "type of enum case is not materializable", ())
+ "enum case has type %0 which includes nested inout parameters",
+ (Type))
ERROR(missing_initializer_def,PointsToFirstBadToken,
"initializer requires a body", ())
diff --git a/include/swift/Basic/Unreachable.h b/include/swift/Basic/Unreachable.h
index c20d874..6ed40ed 100644
--- a/include/swift/Basic/Unreachable.h
+++ b/include/swift/Basic/Unreachable.h
@@ -18,18 +18,11 @@
#ifndef SWIFT_BASIC_UNREACHABLE_H
#define SWIFT_BASIC_UNREACHABLE_H
+#include "llvm/Support/Compiler.h"
#include <assert.h>
#include <stdlib.h>
-#ifdef __GNUC__
-#define SWIFT_ATTRIBUTE_NORETURN __attribute__((noreturn))
-#elif defined(_MSC_VER)
-#define SWIFT_ATTRIBUTE_NORETURN __declspec(noreturn)
-#else
-#define SWIFT_ATTRIBUTE_NORETURN
-#endif
-
-SWIFT_ATTRIBUTE_NORETURN
+LLVM_ATTRIBUTE_NORETURN
inline static void swift_unreachable(const char* msg) {
assert(false && msg);
(void)msg;
diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp
index 183c005..85892ef 100644
--- a/lib/Sema/TypeCheckAttr.cpp
+++ b/lib/Sema/TypeCheckAttr.cpp
@@ -1831,6 +1831,9 @@
}
void TypeChecker::checkTypeModifyingDeclAttributes(VarDecl *var) {
+ if (!var->hasType())
+ return;
+
if (auto *attr = var->getAttrs().getAttribute<OwnershipAttr>())
checkOwnershipAttr(var, attr);
if (auto *attr = var->getAttrs().getAttribute<AutoClosureAttr>()) {
@@ -1858,7 +1861,7 @@
void TypeChecker::checkAutoClosureAttr(ParamDecl *PD, AutoClosureAttr *attr) {
// The paramdecl should have function type, and we restrict it to functions
// taking ().
- auto *FTy = PD->getType()->getAs<FunctionType>();
+ auto *FTy = PD->getInterfaceType()->getAs<FunctionType>();
if (!FTy) {
diagnose(attr->getLocation(), diag::autoclosure_function_type);
attr->setInvalid();
@@ -1912,7 +1915,7 @@
void TypeChecker::checkNoEscapeAttr(ParamDecl *PD, NoEscapeAttr *attr) {
// The paramdecl should have function type.
- auto *FTy = PD->getType()->getAs<FunctionType>();
+ auto *FTy = PD->getInterfaceType()->getAs<FunctionType>();
if (FTy == nullptr) {
diagnose(attr->getLocation(), diag::noescape_function_type);
attr->setInvalid();
diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp
index 4946d87..01ceffd 100644
--- a/lib/Sema/TypeCheckDecl.cpp
+++ b/lib/Sema/TypeCheckDecl.cpp
@@ -6265,7 +6265,8 @@
// Require the carried type to be materializable.
if (EED->getArgumentType() &&
!EED->getArgumentType()->isMaterializable()) {
- TC.diagnose(EED->getLoc(), diag::enum_element_not_materializable);
+ TC.diagnose(EED->getLoc(), diag::enum_element_not_materializable,
+ EED->getArgumentType());
EED->setInterfaceType(ErrorType::get(TC.Context));
EED->setInvalid();
}
diff --git a/test/Constraints/lvalues.swift b/test/Constraints/lvalues.swift
index 47a0c2f..3b91f75 100644
--- a/test/Constraints/lvalues.swift
+++ b/test/Constraints/lvalues.swift
@@ -159,9 +159,9 @@
}
// Don't infer inout types.
-var ir = &i // expected-error{{type 'inout Int' of variable is not materializable}} \
+var ir = &i // expected-error{{variable has type 'inout Int' which includes nested inout parameters}} \
// expected-error{{'&' can only appear immediately in a call argument list}}
-var ir2 = ((&i)) // expected-error{{type 'inout Int' of variable is not materializable}} \
+var ir2 = ((&i)) // expected-error{{variable has type 'inout Int' which includes nested inout parameters}} \
// expected-error{{'&' can only appear immediately in a call argument list}}
// <rdar://problem/17133089>
diff --git a/test/attr/attr_noescape.swift b/test/attr/attr_noescape.swift
index 4aa6b19..1404749 100644
--- a/test/attr/attr_noescape.swift
+++ b/test/attr/attr_noescape.swift
@@ -330,8 +330,11 @@
// type attribute and decl attribute
func noescapeD(@noescape f: @escaping () -> Bool) {} // expected-error {{@noescape is now an attribute on a parameter type, instead of on the parameter itself}} {{16-25=}} {{29-29=@noescape }}
func noescapeT(f: @noescape () -> Bool) {} // expected-warning{{@noescape is the default and is deprecated}} {{19-29=}}
+func noescapeG<T>(@noescape f: () -> T) {} // expected-error{{@noescape is now an attribute on a parameter type, instead of on the parameter itself}}
+
func autoclosureD(@autoclosure f: () -> Bool) {} // expected-error {{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}} {{19-31=}} {{35-35=@autoclosure }}
func autoclosureT(f: @autoclosure () -> Bool) {} // ok
+func autoclosureG<T>(@autoclosure f: () -> T) {} // expected-error{{@autoclosure is now an attribute on a parameter type, instead of on the parameter itself}}
func noescapeD_noescapeT(@noescape f: @noescape () -> Bool) {} // expected-error {{@noescape is now an attribute on a parameter type, instead of on the parameter itself}}
// expected-warning@-1{{@noescape is the default and is deprecated}} {{39-49=}}
diff --git a/test/decl/enum/enumtest.swift b/test/decl/enum/enumtest.swift
index 12e4175..58783e9 100644
--- a/test/decl/enum/enumtest.swift
+++ b/test/decl/enum/enumtest.swift
@@ -311,3 +311,9 @@
case Foo
}
print(SyntheticMember.Foo.hasValue) // expected-error {{value of type 'SyntheticMember' has no member 'hasValue'}}
+
+// Non-materializable argument type
+enum Lens<T> {
+ case foo(inout T) // expected-error {{'inout' may only be used on parameters}}
+ case bar(inout T, Int) // expected-error {{'inout' may only be used on parameters}}
+}
diff --git a/test/expr/expressions.swift b/test/expr/expressions.swift
index 99ebdc2..9b09b86 100644
--- a/test/expr/expressions.swift
+++ b/test/expr/expressions.swift
@@ -523,9 +523,9 @@
takesExplicitInt(&x)
takesInt(&x) // expected-error{{'&' used with non-inout argument of type 'Int'}}
var y = &x // expected-error{{'&' can only appear immediately in a call argument list}} \
- // expected-error {{type 'inout Int' of variable is not materializable}}
+ // expected-error {{variable has type 'inout Int' which includes nested inout parameters}}
var z = &arg // expected-error{{'&' can only appear immediately in a call argument list}} \
- // expected-error {{type 'inout Int' of variable is not materializable}}
+ // expected-error {{variable has type 'inout Int' which includes nested inout parameters}}
takesExplicitInt(5) // expected-error {{cannot pass immutable value as inout argument: literals are not mutable}}
}
@@ -810,7 +810,7 @@
(true ? &x : &y) // expected-error 2 {{'&' can only appear immediately in a call argument list}}
// expected-warning @-1 {{expression of type 'inout Int' is unused}}
let a = (true ? &x : &y) // expected-error 2 {{'&' can only appear immediately in a call argument list}}
- // expected-error @-1 {{type 'inout Int' of variable is not materializable}}
+ // expected-error @-1 {{variable has type 'inout Int' which includes nested inout parameters}}
inoutTests(true ? &x : &y); // expected-error 2 {{'&' can only appear immediately in a call argument list}}
diff --git a/validation-test/compiler_crashers_2_fixed/0064-rdar27627862.swift b/validation-test/compiler_crashers_2_fixed/0064-rdar27627862.swift
new file mode 100644
index 0000000..4a2e760
--- /dev/null
+++ b/validation-test/compiler_crashers_2_fixed/0064-rdar27627862.swift
@@ -0,0 +1,9 @@
+// RUN: %target-swift-frontend %s -emit-ir
+
+enum Term<S> where S: Sequence, S.Iterator.Element == Term {
+ case Cons(head: String, tail: S)
+}
+
+func produce<S>(s: S) -> Term<S> {
+ return .Cons(head: "hi", tail: s)
+}
diff --git a/validation-test/compiler_crashers/28595-typeincontext-isnull-no-contextual-type-set-yet.swift b/validation-test/compiler_crashers_fixed/28595-typeincontext-isnull-no-contextual-type-set-yet.swift
similarity index 87%
rename from validation-test/compiler_crashers/28595-typeincontext-isnull-no-contextual-type-set-yet.swift
rename to validation-test/compiler_crashers_fixed/28595-typeincontext-isnull-no-contextual-type-set-yet.swift
index be76c76..3414ca5 100644
--- a/validation-test/compiler_crashers/28595-typeincontext-isnull-no-contextual-type-set-yet.swift
+++ b/validation-test/compiler_crashers_fixed/28595-typeincontext-isnull-no-contextual-type-set-yet.swift
@@ -5,6 +5,6 @@
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
-// RUN: not --crash %target-swift-frontend %s -emit-ir
+// RUN: not %target-swift-frontend %s -emit-ir
// REQUIRES: asserts
protocol b{func a(@autoclosure())