Skip to content

Commit 8a5b97a

Browse files
committed
Revert "[clang] [modules] Add err_main_in_named_module (#146247)"
This reverts commit 473769e. It breaks test in libc++ See #146247
1 parent 545cdca commit 8a5b97a

File tree

5 files changed

+0
-18
lines changed

5 files changed

+0
-18
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,6 @@ Improvements to Clang's diagnostics
655655
#GH69470, #GH59391, #GH58172, #GH46215, #GH45915, #GH45891, #GH44490,
656656
#GH36703, #GH32903, #GH23312, #GH69874.
657657

658-
- A warning is now emitted when ``main`` is attached to a named module,
659-
which can be turned off with ``-Wno-main-attached-to-named-module``. (#GH146247)
660-
661658
- Clang now avoids issuing `-Wreturn-type` warnings in some cases where
662659
the final statement of a non-void function is a `throw` expression, or
663660
a call to a function that is trivially known to always throw (i.e., its

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,10 +1062,6 @@ def err_constexpr_main : Error<
10621062
"'main' is not allowed to be declared %select{constexpr|consteval}0">;
10631063
def err_deleted_main : Error<"'main' is not allowed to be deleted">;
10641064
def err_mainlike_template_decl : Error<"%0 cannot be a template">;
1065-
def warn_main_in_named_module
1066-
: ExtWarn<"'main' should not be attached to a named module; consider "
1067-
"adding C++ language linkage">,
1068-
InGroup<DiagGroup<"main-attached-to-named-module">>;
10691065
def err_main_returns_nonint : Error<"'main' must return 'int'">;
10701066
def ext_main_returns_nonint : ExtWarn<"return type of 'main' is not 'int'">,
10711067
InGroup<MainReturnType>;

clang/lib/Sema/SemaDecl.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12489,14 +12489,6 @@ void Sema::CheckMain(FunctionDecl *FD, const DeclSpec &DS) {
1248912489
: FixItHint());
1249012490
FD->setInvalidDecl(true);
1249112491
}
12492-
12493-
// In C++ [basic.start.main]p3, it is said a program attaching main to a
12494-
// named module is ill-formed.
12495-
if (FD->isInNamedModule()) {
12496-
const SourceLocation start = FD->getTypeSpecStartLoc();
12497-
Diag(start, diag::warn_main_in_named_module)
12498-
<< FixItHint::CreateInsertion(start, "extern \"C++\" ", true);
12499-
}
1250012492
}
1250112493

1250212494
// Treat protoless main() as nullary.

clang/test/Driver/autocomplete.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
// RUN: %clang --autocomplete=-Wma | FileCheck %s -check-prefix=WARNING
112112
// WARNING: -Wmacro-redefined
113113
// WARNING-NEXT: -Wmain
114-
// WARNING-NEXT: -Wmain-attached-to-named-module
115114
// WARNING-NEXT: -Wmain-return-type
116115
// WARNING-NEXT: -Wmalformed-warning-check
117116
// WARNING-NEXT: -Wmany-braces-around-scalar-init

clang/test/SemaCXX/modules.cppm

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ int n;
6868
//--- test3.cpp
6969
export module bar;
7070

71-
int main() {} // expected-warning {{'main' should not be attached to a named module; consider adding C++ language linkage}}
72-
7371
static int m;
7472

7573
int n;

0 commit comments

Comments
 (0)