fix #17351; switch to c++17 and remove hacks (#20407)

* fix #17351; switch to c++17

* remove workaround
This commit is contained in:
ringabout
2022-09-23 17:16:43 +08:00
committed by GitHub
parent be4bd8a0ed
commit 47b59e4d33
3 changed files with 14 additions and 5 deletions

View File

@@ -376,8 +376,7 @@ proc genObjectInit(p: BProc, section: TCProcSection, t: PType, a: var TLoc,
else:
linefmt(p, section, "$1.m_type = $2;$n", [r, genTypeInfoV1(p.module, t, a.lode.info)])
of frEmbedded:
# inheritance in C++ does not allow struct initialization: bug #18410
if not p.module.compileToCpp and optTinyRtti in p.config.globalOptions:
if optTinyRtti in p.config.globalOptions:
var tmp: TLoc
if mode == constructRefObj:
let objType = t.skipTypes(abstractInst+{tyRef})

View File

@@ -89,7 +89,7 @@ compiler gcc:
asmStmtFrmt: "__asm__($1);$n",
structStmtFmt: "$1 $3 $2 ", # struct|union [packed] $name
produceAsm: gnuAsmListing,
cppXsupport: "-std=gnu++14 -funsigned-char",
cppXsupport: "-std=gnu++17 -funsigned-char",
props: {hasSwitchRange, hasComputedGoto, hasCpp, hasGcGuard, hasGnuAsm,
hasAttribute})
@@ -116,7 +116,7 @@ compiler nintendoSwitchGCC:
asmStmtFrmt: "asm($1);$n",
structStmtFmt: "$1 $3 $2 ", # struct|union [packed] $name
produceAsm: gnuAsmListing,
cppXsupport: "-std=gnu++14 -funsigned-char",
cppXsupport: "-std=gnu++17 -funsigned-char",
props: {hasSwitchRange, hasComputedGoto, hasCpp, hasGcGuard, hasGnuAsm,
hasAttribute})

View File

@@ -12,4 +12,14 @@ type
proc p(): Option[O] = none(O)
doAssert $p() == "none(O)"
doAssert $p() == "none(O)"
# bug #17351
type
Foo = object of RootObj
Foo2 = object of Foo
Bar = object
x: Foo2
var b = Bar()
discard b