Skip to content

Commit

Permalink
fix nim-lang#17351; switch to c++17 and remove hacks (nim-lang#20407)
Browse files Browse the repository at this point in the history
* fix nim-lang#17351; switch to c++17

* remove workaround
  • Loading branch information
ringabout authored and capocasa committed Mar 31, 2023
1 parent 508066a commit df7a0df
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 1 addition & 2 deletions compiler/cgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions compiler/extccomp.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -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})

Expand Down
12 changes: 11 additions & 1 deletion tests/cpp/torc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit df7a0df

Please sign in to comment.