Skip to content

Commit 73a3827

Browse files
authored
Merge pull request #65346 from apple/es-rel-unicodes
[5.9] Allow all unicode characters in package-name input
2 parents 4a9f0f9 + 45a9d60 commit 73a3827

File tree

3 files changed

+33
-13
lines changed

3 files changed

+33
-13
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ ERROR(error_bad_export_as_name,none,
192192
"export-as name \"%0\" is not a valid identifier",
193193
(StringRef))
194194

195-
ERROR(error_bad_package_name,none,
196-
"package name \"%0\" is not a valid identifier",
197-
(StringRef))
195+
ERROR(error_empty_package_name,none,
196+
"package-name is empty",
197+
())
198198
ERROR(error_stdlib_not_found,Fatal,
199199
"unable to load standard library for target '%0'", (StringRef))
200200
ERROR(error_module_alias_invalid_format,none,

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,8 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
804804

805805
if (const Arg *A = Args.getLastArg(OPT_package_name)) {
806806
auto pkgName = A->getValue();
807-
if (!Lexer::isIdentifier(pkgName))
808-
Diags.diagnose(SourceLoc(), diag::error_bad_package_name, pkgName);
807+
if (StringRef(pkgName).empty())
808+
Diags.diagnose(SourceLoc(), diag::error_empty_package_name);
809809
else
810810
Opts.PackageName = pkgName;
811811
}
Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
// RUN: %empty-directory(%t)
22

3-
// Package name should have valid characters
4-
// RUN: not %target-swift-frontend -module-name Logging -package-name My-Logging%Pkg %s -emit-module -emit-module-path %t/Logging.swiftmodule 2> %t/resultA.output
5-
// RUN: %FileCheck %s -input-file %t/resultA.output -check-prefix CHECK-BAD
6-
// CHECK-BAD: error: package name "My-Logging%Pkg" is not a valid identifier
7-
// CHECK-BAD: error: decl has a package access level but no -package-name was passed
8-
93
// Package name should not be empty
104
// RUN: not %target-swift-frontend -typecheck %s -package-name "" 2>&1 | %FileCheck %s -check-prefix CHECK-EMPTY
11-
// CHECK-EMPTY: error: package name "" is not a valid identifier
5+
// CHECK-EMPTY: error: package-name is empty
126
// CHECK-EMPTY: error: decl has a package access level but no -package-name was passed
137

148
// If package access level is used but no package-name is passed, it should error
@@ -23,5 +17,31 @@
2317
// RUN: %target-swift-frontend -module-name Logging -package-name Swift %s -emit-module -emit-module-path %t/Logging.swiftmodule
2418
// RUN: test -f %t/Logging.swiftmodule
2519

26-
package func log() {}
20+
// Package name can have any unicode characters
21+
22+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name " "
23+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "swift-util.log"
24+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "swift$util.log"
25+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "swift\$util.log"
26+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "swift*util.log"
27+
28+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "-swift*util.log"
29+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name ".swift*util-log"
30+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "\#swift#utillog"
31+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "swift^util\&lo\(g+@"
32+
33+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "swift-util$tools*log"
34+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "swift/utils/tools/log.git"
2735

36+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "foo bar baz git"
37+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "My-Logging%Pkg"
38+
39+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name Προϊόν
40+
41+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name “\n”
42+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name “\\n”
43+
44+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "a\\nb"
45+
// RUN: %target-swift-frontend %s -typecheck -verify -package-name "a\nde-f.g ~!@#$%^&<>?/|:"
46+
47+
package func log() {}

0 commit comments

Comments
 (0)