Skip to content

Commit ab9608c

Browse files
committed
[Macros] Add tests for redeclarations of macros
1 parent e2c66cb commit ab9608c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,6 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
19841984

19851985
void visitMacroDecl(MacroDecl *MD) {
19861986
TypeChecker::checkDeclAttributes(MD);
1987-
// FIXME: Check for redeclarations
19881987
checkAccessControl(MD);
19891988
}
19901989

test/Macros/macros_diagnostics.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ internal struct X { } // expected-note{{type declared here}}
1313
public macro createAnX: X = BuiltinMacros.Blah
1414
// expected-error@-1{{macro cannot be declared public because its result type uses an internal type}}
1515

16+
macro m1: Int = A.B
17+
macro m1: Float = A.B
18+
19+
macro m2: Int = A.B // expected-note{{'m2' previously declared here}}
20+
macro m2: Int = A.B // expected-error{{invalid redeclaration of 'm2'}}
21+
22+
macro m3(_: Int) -> Int = A.B
23+
macro m3(_: Int) -> Float = A.B
24+
25+
macro m4(_: Int) -> Int = A.B // expected-note{{'m4' previously declared here}}
26+
macro m4(_: Int) -> Int = A.B // expected-error{{invalid redeclaration of 'm4'}}
27+
1628
func test(a: Int, b: Int) {
1729
// FIXME: Bad diagnostic.
1830
let s = #stringify<Int, Int>(a + b) // expected-error{{type of expression is ambiguous without more context}}

0 commit comments

Comments
 (0)