Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ddmd/attrib.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import ddmd.mtype;
import ddmd.parse;
import ddmd.root.outbuffer;
import ddmd.root.rmem;
import ddmd.target;
import ddmd.tokens;
import ddmd.utf;
import ddmd.utils;
Expand Down Expand Up @@ -499,7 +500,7 @@ extern (C++) final class LinkDeclaration : AttribDeclaration
{
super(decl);
//printf("LinkDeclaration(linkage = %d, decl = %p)\n", p, decl);
linkage = p;
linkage = (p == LINKsystem) ? Target.systemLinkage() : p;
}

override Dsymbol syntaxCopy(Dsymbol s)
Expand Down
2 changes: 2 additions & 0 deletions src/ddmd/globals.d
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ enum LINK : int
windows,
pascal,
objc,
system,
}

alias LINKdefault = LINK.def;
Expand All @@ -417,6 +418,7 @@ alias LINKcpp = LINK.cpp;
alias LINKwindows = LINK.windows;
alias LINKpascal = LINK.pascal;
alias LINKobjc = LINK.objc;
alias LINKsystem = LINK.system;

enum CPPMANGLE : int
{
Expand Down
1 change: 1 addition & 0 deletions src/ddmd/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ enum LINK
LINKwindows,
LINKpascal,
LINKobjc,
LINKsystem,
};

enum CPPMANGLE
Expand Down
2 changes: 2 additions & 0 deletions src/ddmd/hdrgen.d
Original file line number Diff line number Diff line change
Expand Up @@ -3202,6 +3202,8 @@ extern (C++) const(char)* linkageToChars(LINK linkage)
return "Pascal";
case LINKobjc:
return "Objective-C";
case LINKsystem:
return "System";
default:
assert(0);
}
Expand Down
3 changes: 1 addition & 2 deletions src/ddmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import ddmd.root.filename;
import ddmd.root.outbuffer;
import ddmd.root.rmem;
import ddmd.root.rootobject;
import ddmd.target;
import ddmd.tokens;

// How multiple declarations are parsed.
Expand Down Expand Up @@ -2194,7 +2193,7 @@ final class Parser(AST) : Lexer
}
else if (id == Id.System)
{
link = Target.systemLinkage();
link = LINKsystem;
}
else
{
Expand Down
1 change: 1 addition & 0 deletions src/ddmd/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ struct Target
// ABI and backend.
static void loadModule(Module *m);
static void prefixName(OutBuffer *buf, LINK linkage);
static LINK systemLinkage();
};

#endif
10 changes: 10 additions & 0 deletions test/fail_compilation/parseStc2.d
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ align(1) align(1) void f12() {}
align align(1) void f13() {}
align(1) align void f14() {}
align(1) align(2) void f15() {}

/*
TEST_OUTPUT:
---
fail_compilation/parseStc2.d(76): Error: redundant linkage extern (System)
fail_compilation/parseStc2.d(77): Error: conflicting linkage extern (System) and extern (C++)
---
*/
extern(System) extern(System) void f16() {}
extern(System) extern(C++) void f17() {}