Skip to content

Commit f41ce33

Browse files
committed
Drop unused MemberRefExpr handling in LegalConstExprVerifier, adjust tests
1 parent 19f3320 commit f41ce33

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

lib/Sema/LegalConstExprVerifier.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -237,19 +237,6 @@ checkSupportedWithSectionAttribute(const Expr *expr,
237237
return std::make_pair(expr, OpaqueDeclRef);
238238
}
239239

240-
// Member references for function names are allowed if non-generic
241-
if (const MemberRefExpr *memberRef = dyn_cast<MemberRefExpr>(expr)) {
242-
if (auto *funcDecl =
243-
dyn_cast<FuncDecl>(memberRef->getMember().getDecl())) {
244-
if (!funcDecl->isGeneric() &&
245-
!funcDecl->getDeclContext()->isGenericContext()) {
246-
continue;
247-
}
248-
return std::make_pair(expr, OpaqueFuncDeclRef);
249-
}
250-
return std::make_pair(expr, OpaqueDeclRef);
251-
}
252-
253240
// DotSelfExpr for metatype references (but only a direct TypeExpr inside)
254241
if (const DotSelfExpr *dotSelfExpr = dyn_cast<DotSelfExpr>(expr)) {
255242
if (const TypeExpr *typeExpr =

test/ConstValues/SectionSyntactic.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
@section("mysection") let boolLiteral1 = true // ok
2222
@section("mysection") let boolLiteral2 = false // ok
2323

24+
// magic literals
25+
@section("mysection") let invalidNonLiteral4 = #line
26+
2427
// operators (should be rejected)
2528
@section("mysection") let invalidOperator1 = 1 + 1
2629
// expected-error@-1{{unsupported operator in a '@const' expression}}
@@ -31,9 +34,11 @@
3134

3235
// non-literal expressions (should be rejected)
3336
@section("mysection") let invalidNonLiteral1 = Int.max
34-
// expected-error@-1{{unable to resolve variable reference in a '@const' expression}}
37+
// expected-error@-1{{not supported in a '@const' expression}}
3538
@section("mysection") let invalidNonLiteral2 = UInt8(42)
3639
// expected-error@-1{{not supported in a '@const' expression}}
40+
@section("mysection") let invalidNonLiteral3 = true.hashValue
41+
// expected-error@-1{{not supported in a '@const' expression}}
3742

3843
func foo() -> Int { return 42 }
3944
func bar(x: Int) -> String { return "test" }
@@ -83,7 +88,7 @@ enum E { case a }
8388

8489
// invalid tuples (should be rejected)
8590
@section("mysection") let invalidTuple1 = (1, 2, Int.max)
86-
// expected-error@-1{{unable to resolve variable reference in a '@const' expression}}
91+
// expected-error@-1{{not supported in a '@const' expression}}
8792
@section("mysection") let invalidTuple2 = (1 + 1, 2)
8893
// expected-error@-1{{unsupported operator in a '@const' expression}}
8994

@@ -120,7 +125,7 @@ struct MyCustomExpressibleByIntegerLiteral: ExpressibleByIntegerLiteral {
120125
// invalid inline array (should be rejected)
121126
@available(SwiftStdlib 6.2, *)
122127
@section("mysection") let invalidInlineArray: InlineArray = [1, 2, 3, Int.max]
123-
// expected-error@-1{{unable to resolve variable reference in a '@const' expression}}
128+
// expected-error@-1{{not supported in a '@const' expression}}
124129

125130
// optionals (should be rejected)
126131
@section("mysection") let optional1: Int? = 42

0 commit comments

Comments
 (0)