Distinguish only between __declspec and __attribute__

This commit is contained in:
def 2015-05-05 20:35:43 +02:00
commit 78c26cbf18
2 changed files with 10 additions and 10 deletions

View file

@ -677,10 +677,10 @@ proc genProcAux(m: BModule, prc: PSym) =
genStmts(p, prc.getBody) # modifies p.locals, p.init, etc. genStmts(p, prc.getBody) # modifies p.locals, p.init, etc.
var generatedProc: Rope var generatedProc: Rope
if sfNoReturn in prc.flags: if sfNoReturn in prc.flags:
if hasNoreturnDeclspec in extccomp.CC[extccomp.cCompiler].props: if {hasNoreturn, hasDeclspec} <= extccomp.CC[extccomp.cCompiler].props:
header = "__declspec(noreturn) " & header header = "__declspec(noreturn) " & header
if sfPure in prc.flags: if sfPure in prc.flags:
if hasNakedDeclspec in extccomp.CC[extccomp.cCompiler].props: if {hasNaked, hasDeclspec} <= extccomp.CC[extccomp.cCompiler].props:
header = "__declspec(naked) " & header header = "__declspec(naked) " & header
generatedProc = rfmt(nil, "$N$1 {$n$2$3$4}$N$N", generatedProc = rfmt(nil, "$N$1 {$n$2$3$4}$N$N",
header, p.s(cpsLocals), p.s(cpsInit), p.s(cpsStmts)) header, p.s(cpsLocals), p.s(cpsInit), p.s(cpsStmts))
@ -723,9 +723,9 @@ proc genProcPrototype(m: BModule, sym: PSym) =
var header = genProcHeader(m, sym) var header = genProcHeader(m, sym)
if sym.typ.callConv != ccInline and crossesCppBoundary(m, sym): if sym.typ.callConv != ccInline and crossesCppBoundary(m, sym):
header = "extern \"C\" " & header header = "extern \"C\" " & header
if sfPure in sym.flags and hasNakedAttribute in CC[cCompiler].props: if sfPure in sym.flags and {hasNaked, hasAttribute} <= CC[cCompiler].props:
header.add(" __attribute__((naked))") header.add(" __attribute__((naked))")
if sfNoReturn in sym.flags and hasNoreturnAttribute in CC[cCompiler].props: if sfNoReturn in sym.flags and {hasNoreturn, hasAttribute} <= CC[cCompiler].props:
header.add(" __attribute__((noreturn))") header.add(" __attribute__((noreturn))")
add(m.s[cfsProcHeaders], rfmt(nil, "$1;$n", header)) add(m.s[cfsProcHeaders], rfmt(nil, "$1;$n", header))

View file

@ -26,10 +26,10 @@ type
hasAssume, # CC has __assume (Visual C extension) hasAssume, # CC has __assume (Visual C extension)
hasGcGuard, # CC supports GC_GUARD to keep stack roots hasGcGuard, # CC supports GC_GUARD to keep stack roots
hasGnuAsm, # CC's asm uses the absurd GNU assembler syntax hasGnuAsm, # CC's asm uses the absurd GNU assembler syntax
hasNakedDeclspec, # CC has __declspec(naked) hasDeclspec, # CC has __declspec(X)
hasNakedAttribute, # CC has __attribute__((naked)) hasAttribute, # CC has __attribute__((X))
hasNoreturnAttribute, # CC has __attribute__((noreturn)) hasNaked, # CC has naked declspec/attribute
hasNoreturnDeclspec # CC has __declspec(noreturn) hasNoreturn # CC has noreturn declspec/attribute
TInfoCCProps* = set[TInfoCCProp] TInfoCCProps* = set[TInfoCCProp]
TInfoCC* = tuple[ TInfoCC* = tuple[
name: string, # the short name of the compiler name: string, # the short name of the compiler
@ -87,7 +87,7 @@ compiler gcc:
structStmtFmt: "$1 $3 $2 ", # struct|union [packed] $name structStmtFmt: "$1 $3 $2 ", # struct|union [packed] $name
packedPragma: "__attribute__((__packed__))", packedPragma: "__attribute__((__packed__))",
props: {hasSwitchRange, hasComputedGoto, hasCpp, hasGcGuard, hasGnuAsm, props: {hasSwitchRange, hasComputedGoto, hasCpp, hasGcGuard, hasGnuAsm,
hasNakedAttribute, hasNoreturnAttribute}) hasAttribute, hasNaked, hasNoreturn})
# LLVM Frontend for GCC/G++ # LLVM Frontend for GCC/G++
compiler llvmGcc: compiler llvmGcc:
@ -129,7 +129,7 @@ compiler vcc:
asmStmtFrmt: "__asm{$n$1$n}$n", asmStmtFrmt: "__asm{$n$1$n}$n",
structStmtFmt: "$3$n$1 $2", structStmtFmt: "$3$n$1 $2",
packedPragma: "#pragma pack(1)", packedPragma: "#pragma pack(1)",
props: {hasCpp, hasAssume, hasNakedDeclspec, hasNoreturnDeclspec}) props: {hasCpp, hasAssume, hasDeclspec, hasNaked, hasNoreturn})
# Intel C/C++ Compiler # Intel C/C++ Compiler
compiler icl: compiler icl: