File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed
Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -911,6 +911,8 @@ def err_mmap_expected_feature : Error<"expected a feature name">;
911911def err_mmap_expected_attribute : Error<"expected an attribute name">;
912912def err_mmap_link_redecalration : Error<"redeclaration of link library '%0'">;
913913def note_mmap_prev_link_declaration : Note<"previously declared here">;
914+ def err_mmap_submodule_link_decl
915+ : Error<"link declaration is not allowed in submodules">;
914916def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">,
915917 InGroup<IgnoredAttributes>;
916918def warn_mmap_mismatched_private_submodule : Warning<
Original file line number Diff line number Diff line change @@ -853,6 +853,12 @@ std::optional<LinkDecl> ModuleMapFileParser::parseLinkDecl(
853853
854854 // Make sure we eat all the tokens when we report the errors so parsing
855855 // can continue.
856+ if (!TopLevel) {
857+ Diags.Report (LD.Location , diag::err_mmap_submodule_link_decl);
858+ HadError = true ;
859+ return std::nullopt ;
860+ }
861+
856862 auto [It, Inserted] =
857863 SeenLinkDecl.insert (std::make_pair (Library, LD.Location ));
858864 if (!Inserted) {
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ module A {
88
99 module B {
1010 header "B.h"
11- link "libraryA "
11+ link "libraryB "
1212 }
1313
1414 link "libraryA"
@@ -41,9 +41,7 @@ module C {
4141// RUN: not clang-scan-deps -compilation-database %t/cdb.json -format \
4242// RUN: experimental-full 2>&1 | FileCheck %s
4343
44- // Note that the link declaration in submodule B does not conflict with the
45- // first link declaration in module A, since we only check link declaration
46- // duplications within the current module.
47- // CHECK: module.modulemap:10:3: error: redeclaration of link library 'libraryA'
44+ // CHECK: module.modulemap:6:5: error: link decl is not allowed in submodules
45+ // CHECK-NEXT: module.modulemap:10:3: error: redeclaration of link library 'libraryA'
4846// CHECK-NEXT: module.modulemap:9:3: note: previously declared here
49- // CHECK-NOT: module.modulemap:15:3: error: redeclaration of link library 'libraryA'
47+ // CHECK-NOT: module.modulemap:15:3: error: redeclaration of link library 'libraryA'
You can’t perform that action at this time.
0 commit comments