Commit 9c8c0e72 authored by Russ Cox's avatar Russ Cox

[dev.cc] cmd/internal/gc: reconvert to pick up bug fixes

Convert using rsc.io/c2go rev a97ff47.

Notable changes:
- %% in format string now correctly preserved
- reintroduce "signal handler" to hide internal faults
  after errors have been printed

Change-Id: Ic5a94f1c3a8015a9054e21c8969b52d964a36c45
Reviewed-on: https://go-review.googlesource.com/5633Reviewed-by: 's avatarRob Pike <r@golang.org>
parent 5b94a47b
......@@ -788,7 +788,7 @@ func evconst(n *Node) {
// which is not quite an ideal error.
case OMOD<<16 | CTFLT:
if n.Diag == 0 {
Yyerror("illegal constant expression: floating-point % operation")
Yyerror("illegal constant expression: floating-point %% operation")
n.Diag = 1
}
......
......@@ -1899,7 +1899,7 @@ func Nconv(n *Node, flag int) string {
dumpdepth--
default:
Fatal("unhandled %N mode")
Fatal("unhandled %%N mode")
}
flag = sf
......
......@@ -449,7 +449,7 @@ simple_stmt:
if $1.Next != nil {
Yyerror("argument count mismatch: %d = %d", count($1), 1);
} else if ($1.N.Op != ONAME && $1.N.Op != OTYPE && $1.N.Op != ONONAME) || isblank($1.N) {
Yyerror("invalid variable name %nil in type switch", $1.N);
Yyerror("invalid variable name %s in type switch", Nconv($1.N, 0));
} else {
$$.Left = dclname($1.N.Sym);
} // it's a colas, so must not re-use an oldname.
......
......@@ -75,15 +75,16 @@ func usage() {
Exit(2)
}
func fault(s int) {
// If we've already complained about things
// in the program, don't bother complaining
// about the seg fault too; let the user clean up
// the code and try again.
func hidePanic() {
if nsavederrors+nerrors > 0 {
errorexit()
// If we've already complained about things
// in the program, don't bother complaining
// about a panic too; let the user clean up
// the code and try again.
if err := recover(); err != nil {
errorexit()
}
}
Fatal("fault")
}
func doversion() {
......@@ -95,7 +96,7 @@ func doversion() {
p = ""
}
sep = ""
if p[0] != 0 {
if p != "" {
sep = " "
}
fmt.Printf("%cg version %s%s%s\n", Thearch.Thechar, obj.Getgoversion(), sep, p)
......@@ -103,6 +104,7 @@ func doversion() {
}
func Main() {
defer hidePanic()
var l *NodeList
var p string
......@@ -1834,8 +1836,14 @@ func (yy) Error(msg string) {
Yyerror("%s", msg)
}
var theparser yyParser
var parsing bool
func yyparse() {
yyParse(yy{})
theparser = yyNewParser()
parsing = true
theparser.Parse(yy{})
parsing = false
}
func yylex(yylval *yySymType) int32 {
......
......@@ -638,7 +638,7 @@ func Fconv(fvp *Mpflt, flag int) string {
if d >= 0 && (flag&obj.FmtSign != 0 /*untyped*/) {
fp += fmt.Sprintf("+")
}
fp += fmt.Sprintf("%g", d)
fp += fmt.Sprintf("%.6g", d)
return fp
}
......
......@@ -36,7 +36,8 @@ func errorexit() {
}
func parserline() int {
if yychar_subr != 0 && yychar_subr != -2 { // parser has one symbol lookahead
if parsing && theparser.Lookahead() > 0 {
// parser has one symbol lookahead
return int(prevlineno)
}
return int(lineno)
......@@ -135,6 +136,9 @@ var yyerror_lastsyntax int
func Yyerror(fmt_ string, args ...interface{}) {
var i int
if fmt_ == "%s" && len(args) == 1 && args[0] == "syntax error" {
nsyntaxerrors++
}
if strings.HasPrefix(fmt_, "syntax error") {
nsyntaxerrors++
......
......@@ -1467,7 +1467,7 @@ yydefault:
if yyDollar[1].list.Next != nil {
Yyerror("argument count mismatch: %d = %d", count(yyDollar[1].list), 1)
} else if (yyDollar[1].list.N.Op != ONAME && yyDollar[1].list.N.Op != OTYPE && yyDollar[1].list.N.Op != ONONAME) || isblank(yyDollar[1].list.N) {
Yyerror("invalid variable name %nil in type switch", yyDollar[1].list.N)
Yyerror("invalid variable name %s in type switch", Nconv(yyDollar[1].list.N, 0))
} else {
yyVAL.node.Left = dclname(yyDollar[1].list.N.Sym)
} // it's a colas, so must not re-use an oldname.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment