Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4464 from 9rnsr/fix14198
[REG2.067a] Issue 14198 - Link failure with Variant
- Loading branch information
Showing
10 changed files
with
206 additions
and
14 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,27 @@ | ||
module std14198.array; | ||
|
||
version(bug14198) | ||
{ | ||
} | ||
else | ||
import std14198.uni; | ||
|
||
struct Appender(A) | ||
{ | ||
alias T = immutable char; | ||
|
||
void put(U)(U item) | ||
if ( | ||
is(U : T) || | ||
is(immutable U == immutable char) | ||
) | ||
{ | ||
import std14198.uni; // necessary | ||
assert(0); | ||
} | ||
} | ||
|
||
Appender!A appender(A)() | ||
{ | ||
return Appender!A(); | ||
} |
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,34 @@ | ||
module std14198.conv; | ||
|
||
template to(T) | ||
{ | ||
T to(A...)(A args) | ||
{ | ||
return toImpl!T(args); | ||
} | ||
} | ||
|
||
T toImpl(T, S)(S value) | ||
if (is(S : T)) | ||
{ | ||
return value; | ||
} | ||
|
||
T toImpl(T, S)(S value) | ||
if (!is(S : T) && | ||
is(T == string)) | ||
{ | ||
alias src = value; | ||
|
||
import std14198.format : FormatSpec; | ||
import std14198.array : appender; | ||
|
||
auto w = appender!T(); | ||
FormatSpec!char f; // necessary | ||
|
||
string str = src ? "true" : "false"; | ||
for (; !str.length; str = str[1..$]) | ||
w.put(str[0]); | ||
|
||
return ""; | ||
} |
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,11 @@ | ||
module std14198.format; | ||
|
||
struct FormatSpec(Char) if (is(Char == char)) | ||
{ | ||
import std14198.conv; | ||
|
||
string toString() | ||
{ | ||
return to!string(true); // necessary | ||
} | ||
} |
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 @@ | ||
module std14198.uni; | ||
|
||
alias CodepointSet = InversionList!(); | ||
|
||
struct InversionList() | ||
{ | ||
import std14198.format; | ||
|
||
void toString(FormatSpec!char fs) // necessary | ||
{ | ||
} | ||
} |
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,27 @@ | ||
module test14198; | ||
|
||
import std14198.conv; | ||
|
||
struct S | ||
{ | ||
ptrdiff_t function() fptr = &handler; | ||
|
||
static ptrdiff_t handler() pure @safe | ||
{ | ||
static if (is(typeof(to!string(false)))) | ||
{ | ||
to!string(false); | ||
// [1] to!string(bool src) should be deduced to pure @safe, and the function will be mangled to: | ||
// --> _D8std141984conv11__T2toTAyaZ9__T2toTbZ2toFNaNbNiNfbZAya | ||
// [2] its object code should be stored in the library file, because it's instantiated in std14188.uni: | ||
// --> FormatSpec!char --> to!string(bool src) in FormatSpec!char.toString() | ||
} | ||
else | ||
static assert(0); | ||
return 0; | ||
} | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
|
||
src=runnable${SEP}extra-files | ||
dir=${RESULTS_DIR}${SEP}runnable | ||
output_file=${dir}/link14198a.sh.out | ||
|
||
if [ $OS == "win32" -o $OS == "win64" ]; then | ||
LIBEXT=.lib | ||
else | ||
LIBEXT=.a | ||
fi | ||
libname=${dir}${SEP}lib14198a${LIBEXT} | ||
|
||
# build library | ||
$DMD -m${MODEL} -I${src} -of${libname} -lib ${src}${SEP}std14198${SEP}array.d ${src}${SEP}std14198${SEP}conv.d ${src}${SEP}std14198${SEP}format.d ${src}${SEP}std14198${SEP}uni.d || exit 1 | ||
|
||
# Do not link failure with library file, regardless the semantic order. | ||
$DMD -m${MODEL} -I${src} -of${dir}${SEP}test14198a${EXE} ${src}${SEP}test14198.d ${libname} || exit 1 | ||
$DMD -m${MODEL} -I${src} -of${dir}${SEP}test14198a${EXE} -version=bug14198 ${src}${SEP}test14198.d ${libname} || exit 1 | ||
|
||
rm ${libname} | ||
rm ${dir}/{test14198a${OBJ},test14198a${EXE}} | ||
|
||
echo Success > ${output_file} |
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,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
src=runnable${SEP}extra-files | ||
dir=${RESULTS_DIR}${SEP}runnable | ||
output_file=${dir}/link14198b.sh.out | ||
|
||
rm -f ${output_file} | ||
|
||
if [ $OS == "win32" -o $OS == "win64" ]; then | ||
LIBEXT=.lib | ||
else | ||
LIBEXT=.a | ||
fi | ||
libname=${dir}${SEP}lib14198b${LIBEXT} | ||
|
||
# Do link failure without library file. | ||
|
||
$DMD -m${MODEL} -I${src} -of${dir}${SEP}test14198b${EXE} ${src}${SEP}test14198.d > ${output_file} 2>&1 | ||
grep -q "_D8std141984conv11__T2toTAyaZ9__T2toTbZ2toFNaNbNiNfbZAya" ${output_file} || exit 1 | ||
|
||
$DMD -m${MODEL} -I${src} -of${dir}${SEP}test14198b${EXE} -version=bug14198 ${src}${SEP}test14198.d > ${output_file} 2>&1 | ||
grep -q "_D8std141984conv11__T2toTAyaZ9__T2toTbZ2toFNaNbNiNfbZAya" ${output_file} || exit 1 | ||
|
||
rm ${dir}/{test14198b${OBJ},test14198b${EXE}} | ||
|
||
echo Success > ${output_file} |