mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
fix Issue 23545 - export int a; should generate dllexport, not dllimport (#14680)
This commit is contained in:
parent
df03a1797d
commit
f1b70f41f7
4 changed files with 32 additions and 8 deletions
7
changelog/dmd.extern-dllimport.dd
Normal file
7
changelog/dmd.extern-dllimport.dd
Normal file
|
@ -0,0 +1,7 @@
|
|||
export int a; now generates dllexport instead of dllimport
|
||||
|
||||
In order to make it dllimport, use:
|
||||
|
||||
---
|
||||
export extern int a;
|
||||
---
|
|
@ -1314,9 +1314,17 @@ extern (C++) class VarDeclaration : Declaration
|
|||
|
||||
override final bool isImportedSymbol() const
|
||||
{
|
||||
if (visibility.kind == Visibility.Kind.export_ && !_init && (storage_class & STC.static_ || parent.isModule()))
|
||||
return true;
|
||||
return false;
|
||||
/* If global variable has `export` and `extern` then it is imported
|
||||
* export int sym1; // definition: exported
|
||||
* export extern int sym2; // declaration: imported
|
||||
* export extern int sym3 = 0; // error, extern cannot have initializer
|
||||
*/
|
||||
bool result =
|
||||
visibility.kind == Visibility.Kind.export_ &&
|
||||
storage_class & STC.extern_ &&
|
||||
(storage_class & STC.static_ || parent.isModule());
|
||||
//printf("isImportedSymbol() %s %d\n", toChars(), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
final bool isCtorinit() const pure nothrow @nogc @safe
|
||||
|
|
|
@ -501,12 +501,18 @@ Symbol *toSymbol(Dsymbol s)
|
|||
|
||||
|
||||
/*************************************
|
||||
* Create Windows import symbol from backend Symbol.
|
||||
* Params:
|
||||
* sym = backend symbol
|
||||
* loc = location for error message purposes
|
||||
* Returns:
|
||||
* import symbol
|
||||
*/
|
||||
|
||||
Symbol *toImport(Symbol *sym, Loc loc)
|
||||
private Symbol *createImport(Symbol *sym, Loc loc)
|
||||
{
|
||||
//printf("Dsymbol.toImport('%s')\n", sym.Sident);
|
||||
char *n = sym.Sident.ptr;
|
||||
//printf("Dsymbol.createImport('%s')\n", sym.Sident.ptr);
|
||||
const char* n = sym.Sident.ptr;
|
||||
import core.stdc.stdlib : alloca;
|
||||
const allocLen = 6 + strlen(n) + 1 + type_paramsize(sym.Stype).sizeof*3 + 1;
|
||||
char *id = cast(char *) alloca(allocLen);
|
||||
|
@ -549,7 +555,7 @@ Symbol *toImport(Declaration ds)
|
|||
{
|
||||
if (!ds.csym)
|
||||
ds.csym = toSymbol(ds);
|
||||
ds.isym = toImport(ds.csym, ds.loc);
|
||||
ds.isym = createImport(ds.csym, ds.loc);
|
||||
}
|
||||
return ds.isym;
|
||||
}
|
||||
|
|
|
@ -6,8 +6,11 @@ int main()
|
|||
return DISABLED;
|
||||
|
||||
version (DigitalMars)
|
||||
version (OSX) // Shared libraries are not yet supported on OSX
|
||||
{
|
||||
// Disable DM Dlls for now, need to redesign it
|
||||
// version (OSX) // Shared libraries are not yet supported on OSX
|
||||
return DISABLED;
|
||||
}
|
||||
|
||||
Vars.set(`SRC`, `$EXTRA_FILES/dll`);
|
||||
Vars.set(`EXE_NAME`, `$OUTPUT_BASE/testdll$EXE`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue