Skip to content

Commit fdec9fd

Browse files
authored
[Clang] Fix export declaration diagnostic message (#149059)
Change the error message from "export declaration can only be used within a module purview" to "export declaration can only be used within a module interface" to be technically accurate. The previous message was misleading because export declarations are actually within a module purview when used in module implementation units, but they are only allowed in module interface units. This addresses the issue pointed out in GitHub issue #149008 where Bigcheese noted that the diagnostic wording was incorrect. Fixes #149008
1 parent 8d21025 commit fdec9fd

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12368,7 +12368,7 @@ def err_export_using_internal : Error<
1236812368
"using declaration referring to %1 with %select{internal|module|unknown}0 "
1236912369
"linkage cannot be exported">;
1237012370
def err_export_not_in_module_interface : Error<
12371-
"export declaration can only be used within a module purview">;
12371+
"export declaration can only be used within a module interface">;
1237212372
def err_export_inline_not_defined : Error<
1237312373
"inline function not defined%select{| before the private module fragment}0">;
1237412374
def err_export_partition_impl : Error<

clang/test/CXX/drs/cwg8xx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
namespace cwg820 { // cwg820: 2.7
1010
export template <class T> struct B {};
1111
// cxx98-17-warning@-1 {{exported templates are unsupported}}
12-
// since-cxx20-error@-2 {{export declaration can only be used within a module purview}}
12+
// since-cxx20-error@-2 {{export declaration can only be used within a module interface}}
1313
export template<typename T> void f() {}
1414
// cxx98-17-warning@-1 {{exported templates are unsupported}}
15-
// since-cxx20-error@-2 {{export declaration can only be used within a module purview}}
15+
// since-cxx20-error@-2 {{export declaration can only be used within a module interface}}
1616
} // namespace cwg820
1717

1818
namespace cwg873 { // cwg873: 3.0

clang/test/CXX/module/dcl.dcl/dcl.module/dcl.module.interface/p1.cppm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
//--- ExportDeclNotInModulePurview.cppm
1111
// expected-error@* {{missing 'export module' declaration in module interface unit}}
12-
export int b; // expected-error {{export declaration can only be used within a module purview}}
12+
export int b; // expected-error {{export declaration can only be used within a module interface}}
1313

1414
//--- A.cppm
1515
// expected-no-diagnostics
@@ -18,7 +18,7 @@ export int a;
1818

1919
//--- AddExport.cppm
2020
module A; // #module-decl
21-
export int b; // expected-error {{export declaration can only be used within a module purview}}
21+
export int b; // expected-error {{export declaration can only be used within a module interface}}
2222
// expected-note@#module-decl {{add 'export' here}}
2323

2424
//--- AddExport2.cppm

clang/test/CXX/module/module.interface/p1.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
//--- errors.cpp
99
module;
10-
export int a; // expected-error {{export declaration can only be used within a module purview}}
10+
export int a; // expected-error {{export declaration can only be used within a module interface}}
1111
export module M;
1212
export int b; // #1
1313
namespace N {
@@ -37,8 +37,8 @@ namespace N {
3737
//--- impl.cpp
3838
module M; // #M
3939

40-
export int b2; // expected-error {{export declaration can only be used within a module purview}}
40+
export int b2; // expected-error {{export declaration can only be used within a module interface}}
4141
namespace N {
42-
export int c2; // expected-error {{export declaration can only be used within a module purview}}
42+
export int c2; // expected-error {{export declaration can only be used within a module interface}}
4343
}
4444
// expected-note@#M 2+{{add 'export'}}

clang/test/Modules/cxx20-10-2-ex1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export int x;
1414
module;
1515

1616
#include "std-10-2-ex1.h"
17-
// [email protected]:* {{export declaration can only be used within a module purview}}
17+
// [email protected]:* {{export declaration can only be used within a module interface}}
1818

1919
export module M1;
2020
export namespace {} // expected-error {{anonymous namespaces cannot be exported}}

clang/test/Modules/cxx20-export-import.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
export module dummy;
1212

1313
//--- test.cpp
14-
export import dummy; // expected-error {{export declaration can only be used within a module purview}}
14+
export import dummy; // expected-error {{export declaration can only be used within a module interface}}

clang/test/Modules/cxx20-import-diagnostics-a.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module;
110110

111111
module AOK1;
112112

113-
export import C; // expected-error {{export declaration can only be used within a module purview}}
113+
export import C; // expected-error {{export declaration can only be used within a module interface}}
114114

115115
int theAnswer () { return 42; }
116116

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// RUN: %clang_cc1 -std=c++20 %s -fsyntax-only -verify
2-
export struct Unit { // expected-error {{export declaration can only be used within a module purview}}
2+
export struct Unit { // expected-error {{export declaration can only be used within a module interface}}
33
bool operator<(const Unit &);
44
};

0 commit comments

Comments
 (0)