-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #69379 - jumbatm:llvm-sigsegv, r=pnkfelix
Fail on multiple declarations of `main`. Closes #67946. Previously, when inserting the entry function, we only checked for duplicate _definitions_ of `main`. However, it's possible to cause problems even only having a duplicate _declaration_. For example, shadowing `main` using an extern block isn't caught by the current check, and causes an assertion failure down the line in in LLVM code. r? @pnkfelix
- Loading branch information
Showing
5 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// build-fail | ||
// error-pattern: entry symbol `main` declared multiple times | ||
// | ||
// See #67946. | ||
|
||
#![allow(warnings)] | ||
fn main() { | ||
extern "Rust" { | ||
fn main(); | ||
} | ||
unsafe { main(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
error: entry symbol `main` declared multiple times | ||
--> $DIR/dupe-symbols-8.rs:7:1 | ||
| | ||
LL | / fn main() { | ||
LL | | extern "Rust" { | ||
LL | | fn main(); | ||
LL | | } | ||
LL | | unsafe { main(); } | ||
LL | | } | ||
| |_^ | ||
| | ||
= help: did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead | ||
|
||
error: aborting due to previous error | ||
|