Skip to content

Commit 0cb749e

Browse files
committed
Permit link decls in submodule declarations.
1 parent 1d8fdda commit 0cb749e

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

clang/include/clang/Basic/DiagnosticLexKinds.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -915,8 +915,10 @@ def err_mmap_expected_attribute : Error<"expected an attribute name">;
915915
def warn_mmap_link_redeclaration : Warning<"redeclaration of link library '%0'">,
916916
InGroup<DiagGroup<"module-link-redeclaration">>, DefaultError;
917917
def note_mmap_prev_link_declaration : Note<"previously declared here">;
918-
def err_mmap_submodule_link_decl
919-
: Error<"link declaration is not allowed in submodules">;
918+
def warn_mmap_submodule_link_decl
919+
: Warning<"link declaration is not allowed in submodules">,
920+
InGroup<DiagGroup<"module-submodule-link-decl">>,
921+
DefaultError;
920922
def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">,
921923
InGroup<IgnoredAttributes>;
922924
def warn_mmap_mismatched_private_submodule : Warning<

clang/lib/Lex/ModuleMapFile.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -856,18 +856,14 @@ std::optional<LinkDecl> ModuleMapFileParser::parseLinkDecl(
856856
// Make sure we eat all the tokens when we report the errors so parsing
857857
// can continue.
858858
if (!Allowed) {
859-
Diags.Report(LD.Location, diag::err_mmap_submodule_link_decl);
860-
HadError = true;
861-
return std::nullopt;
859+
Diags.Report(LD.Location, diag::warn_mmap_submodule_link_decl);
862860
}
863861

864862
auto [It, Inserted] =
865863
SeenLinkDecl.insert(std::make_pair(Library, LD.Location));
866864
if (!Inserted) {
867865
Diags.Report(LD.Location, diag::warn_mmap_link_redeclaration) << Library;
868866
Diags.Report(It->second, diag::note_mmap_prev_link_declaration);
869-
HadError = true;
870-
return std::nullopt;
871867
}
872868

873869
return std::move(LD);

clang/test/ClangScanDeps/link-libraries-diag-dup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module C {
5151

5252
// Note that module D does not report an error because it is explicit.
5353
// Therefore we can use CHECK-NEXT for the redeclaration error on line 15.
54-
// CHECK: module.modulemap:6:5: error: link declaration is not allowed in submodules
54+
// CHECK: module.modulemap:6:5: error: link declaration is not allowed in submodules [-Wmodule-submodule-link-decl]
5555
// CHECK-NEXT: module.modulemap:15:3: error: redeclaration of link library 'libraryA' [-Wmodule-link-redeclaration]
5656
// CHECK-NEXT: module.modulemap:14:3: note: previously declared here
5757
// CHECK-NOT: module.modulemap:20:3: error: redeclaration of link library 'libraryA'

0 commit comments

Comments
 (0)