-
-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start deprecation period of identical functions in a single module
- Loading branch information
Showing
8 changed files
with
84 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Usage of identical functions in a single module | ||
|
||
A binary should never contain multiple versions of a symbol. | ||
Before this version, it was allowed to provide multiple implementation for a function, | ||
even if they result in the same mangling, which can result in undefined behavior: | ||
|
||
--- | ||
extern(C): | ||
void foo(int) { } | ||
void foo(double) { } // will error now | ||
--- | ||
|
||
However, it's still allowed to have multiple declarations as long as there's at | ||
most one implementation: | ||
|
||
--- | ||
extern(C): | ||
void foo(int) { } | ||
void foo(double); | ||
--- | ||
|
||
Note that this change is only relevant for mangling schemes that do no support | ||
overloading like `extern(C)`. |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
// REQUIRED_ARGS: -de | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail5634.d(9): Error: function `D main` function `D main()` conflicts with previous declaration at fail_compilation/fail5634.d(8) | ||
--- | ||
*/ | ||
void main() { } | ||
void 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
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 |
---|---|---|
|
@@ -46,7 +46,7 @@ S2000 bar2() | |
} | ||
|
||
|
||
void bar2() | ||
void bar3() | ||
{ | ||
int i; | ||
char c; | ||
|
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,31 @@ | ||
/* | ||
REQUIRED_ARGS: -de | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/test18385.d(13): Deprecation: function `test18385.foo` function `test18385.foo(double)` cannot be overloaded with another `extern(C)` function at fail_compilation/test18385.d(12) | ||
fail_compilation/test18385.d(18): Deprecation: function `test18385.S.foo` function `test18385.S.foo(double)` cannot be overloaded with another `extern(C)` function at fail_compilation/test18385.d(17) | ||
--- | ||
*/ | ||
|
||
extern (C): | ||
|
||
void foo(int) { } | ||
void foo(double) { } | ||
|
||
struct S | ||
{ | ||
static void foo(int) {} | ||
static void foo(double) {} | ||
} | ||
|
||
void foo2(int) { } | ||
extern(D) void foo2(double) { } // OK as it has a different mangling | ||
|
||
void foo3(int) { } | ||
void foo3(double); // duplicate declarations are allowed | ||
|
||
void foo4(); | ||
void foo4() { } | ||
|
||
extern(D) void foo5(); | ||
extern(D) void foo5() { } |