diff options
author | Araq <rumpf_a@web.de> | 2015-04-24 17:07:36 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-04-25 23:16:57 +0200 |
commit | ecc009093933887ab692efd5db099d752a1d2e6b (patch) | |
tree | 5b30ece9cbc8f4f7990bcfa7a8ebf8ff4d2fa155 | |
parent | 4d20aafb5eb0e193c031f52998d50fdf905ab7e8 (diff) | |
download | Nim-ecc009093933887ab692efd5db099d752a1d2e6b.tar.gz |
fixes #2551; fixes #2212; breaks bootstrapping in debug mode; bootstrap with -d:release
-rw-r--r-- | compiler/ccgstmts.nim | 4 | ||||
-rw-r--r-- | compiler/ccgtypes.nim | 19 | ||||
-rw-r--r-- | compiler/ccgutils.nim | 2 | ||||
-rw-r--r-- | lib/nimbase.h | 10 | ||||
-rw-r--r-- | tests/ccgbugs/tpartialcs.nim | 20 |
5 files changed, 38 insertions, 17 deletions
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index b6572d960..1d642db60 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -812,7 +812,7 @@ proc genTryCpp(p: BProc, t: PNode, d: var TLoc) = length = sonsLen(t) endBlock(p, ropecg(p.module, "} catch (NimException& $1) {$n", [exc])) if optStackTrace in p.options: - linefmt(p, cpsStmts, "#setFrame((TFrame*)&F);$n") + linefmt(p, cpsStmts, "#setFrame((TFrame*)&FR);$n") inc p.inExceptBlock i = 1 var catchAllPresent = false @@ -912,7 +912,7 @@ proc genTry(p: BProc, t: PNode, d: var TLoc) = startBlock(p, "else {$n") linefmt(p, cpsStmts, "#popSafePoint();$n") if optStackTrace in p.options: - linefmt(p, cpsStmts, "#setFrame((TFrame*)&F);$n") + linefmt(p, cpsStmts, "#setFrame((TFrame*)&FR);$n") inc p.inExceptBlock var i = 1 while (i < length) and (t.sons[i].kind == nkExceptBranch): diff --git a/compiler/ccgtypes.nim b/compiler/ccgtypes.nim index 60ebf591b..9cbb81fad 100644 --- a/compiler/ccgtypes.nim +++ b/compiler/ccgtypes.nim @@ -11,20 +11,21 @@ # ------------------------- Name Mangling -------------------------------- -proc mangleField(name: string): string = - result = mangle(name) - result[0] = result[0].toUpper # Mangling makes everything lowercase, - # but some identifiers are C keywords - proc isKeyword(w: PIdent): bool = - # nimrod and C++ share some keywords - # it's more efficient to test the whole nimrod keywords range + # Nim and C++ share some keywords + # it's more efficient to test the whole Nim keywords range case w.id of ccgKeywordsLow..ccgKeywordsHigh, nimKeywordsLow..nimKeywordsHigh, ord(wInline): return true else: return false +proc mangleField(name: PIdent): string = + result = mangle(name.s) + if isKeyword(name): + result[0] = result[0].toUpper # Mangling makes everything lowercase, + # but some identifiers are C keywords + proc mangleName(s: PSym): Rope = result = s.loc.r if result == nil: @@ -379,7 +380,7 @@ proc mangleRecFieldName(field: PSym, rectype: PType): Rope = ({sfImportc, sfExportc} * rectype.sym.flags != {}): result = field.loc.r else: - result = rope(mangleField(field.name.s)) + result = rope(mangleField(field.name)) if result == nil: internalError(field.info, "mangleRecFieldName") proc genRecordFieldsAux(m: BModule, n: PNode, @@ -642,7 +643,7 @@ proc getTypeDescAux(m: BModule, typ: PType, check: var IntSet): Rope = result.add getTypeDescAux(m, typeInSlot, check) else: inc i - + if chunkStart != 0: result.add cppName.data.substr(chunkStart) else: diff --git a/compiler/ccgutils.nim b/compiler/ccgutils.nim index 4e94c1867..4ba6643ec 100644 --- a/compiler/ccgutils.nim +++ b/compiler/ccgutils.nim @@ -176,7 +176,7 @@ proc mangle*(name: string): string = result = newStringOfCap(name.len) case name[0] of Letters: - result.add(name[0].toLower) + result.add(name[0]) of Digits: result.add("N" & name[0]) else: diff --git a/lib/nimbase.h b/lib/nimbase.h index e9dad0bb7..eea618bac 100644 --- a/lib/nimbase.h +++ b/lib/nimbase.h @@ -343,15 +343,15 @@ struct TFrame { }; #define nimfr(proc, file) \ - TFrame F; \ - F.procname = proc; F.filename = file; F.line = 0; F.len = 0; nimFrame(&F); + TFrame FR; \ + FR.procname = proc; FR.filename = file; FR.line = 0; FR.len = 0; nimFrame(&FR); #define nimfrs(proc, file, slots, length) \ - struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; TVarSlot s[slots];} F; \ - F.procname = proc; F.filename = file; F.line = 0; F.len = length; nimFrame((TFrame*)&F); + struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; TVarSlot s[slots];} FR; \ + FR.procname = proc; FR.filename = file; FR.line = 0; FR.len = length; nimFrame((TFrame*)&FR); #define nimln(n, file) \ - F.line = n; F.filename = file; + FR.line = n; FR.filename = file; #define NIM_POSIX_INIT __attribute__((constructor)) diff --git a/tests/ccgbugs/tpartialcs.nim b/tests/ccgbugs/tpartialcs.nim new file mode 100644 index 000000000..12ff65c37 --- /dev/null +++ b/tests/ccgbugs/tpartialcs.nim @@ -0,0 +1,20 @@ + +# bug #2551 + +type Tup = tuple + A, a: int + +type Obj = object + A, a: int + +var x: Tup # This works. +var y: Obj # This doesn't. + +# bug #2212 + +proc f() = + let + p = 1.0 + P = 0.25 + 0.5 + +f() |