diff options
author | ringabout <43030857+ringabout@users.noreply.github.com> | 2022-09-23 17:16:43 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-23 11:16:43 +0200 |
commit | 47b59e4d3315dbcb0b17d305f43cc35e4eb89e51 (patch) | |
tree | ef189fb8141b8269cccfaba5905281a3c17c21ef | |
parent | be4bd8a0edd527b24679372b8cb9d2afa548056d (diff) | |
download | Nim-47b59e4d3315dbcb0b17d305f43cc35e4eb89e51.tar.gz |
fix #17351; switch to c++17 and remove hacks (#20407)
* fix #17351; switch to c++17 * remove workaround
-rw-r--r-- | compiler/cgen.nim | 3 | ||||
-rw-r--r-- | compiler/extccomp.nim | 4 | ||||
-rw-r--r-- | tests/cpp/torc.nim | 12 |
3 files changed, 14 insertions, 5 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 3896a46ca..1e2608108 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -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}) diff --git a/compiler/extccomp.nim b/compiler/extccomp.nim index 6d306d0e6..be79bb398 100644 --- a/compiler/extccomp.nim +++ b/compiler/extccomp.nim @@ -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}) diff --git a/tests/cpp/torc.nim b/tests/cpp/torc.nim index 7fc474f94..636105f31 100644 --- a/tests/cpp/torc.nim +++ b/tests/cpp/torc.nim @@ -12,4 +12,14 @@ type proc p(): Option[O] = none(O) -doAssert $p() == "none(O)" \ No newline at end of file +doAssert $p() == "none(O)" + +# bug #17351 +type + Foo = object of RootObj + Foo2 = object of Foo + Bar = object + x: Foo2 + +var b = Bar() +discard b |