mirror of
https://github.com/golang/go
synced 2024-11-25 05:07:56 -07:00
gc: echo literal in error message
Fixes #1192. R=ken2 CC=golang-dev https://golang.org/cl/4794062
This commit is contained in:
parent
100a034120
commit
49b70d01c0
@ -698,6 +698,7 @@ EXTERN int nsyntaxerrors;
|
|||||||
EXTERN int safemode;
|
EXTERN int safemode;
|
||||||
EXTERN char namebuf[NSYMB];
|
EXTERN char namebuf[NSYMB];
|
||||||
EXTERN char lexbuf[NSYMB];
|
EXTERN char lexbuf[NSYMB];
|
||||||
|
EXTERN char litbuf[NSYMB];
|
||||||
EXTERN char debug[256];
|
EXTERN char debug[256];
|
||||||
EXTERN Sym* hash[NHASH];
|
EXTERN Sym* hash[NHASH];
|
||||||
EXTERN Sym* importmyname; // my name for package
|
EXTERN Sym* importmyname; // my name for package
|
||||||
|
@ -728,6 +728,7 @@ l0:
|
|||||||
yylval.val.u.sval = (Strlit*)cp;
|
yylval.val.u.sval = (Strlit*)cp;
|
||||||
yylval.val.ctype = CTSTR;
|
yylval.val.ctype = CTSTR;
|
||||||
DBG("lex: string literal\n");
|
DBG("lex: string literal\n");
|
||||||
|
strcpy(litbuf, "string literal");
|
||||||
return LLITERAL;
|
return LLITERAL;
|
||||||
|
|
||||||
case '\'':
|
case '\'':
|
||||||
@ -744,6 +745,7 @@ l0:
|
|||||||
mpmovecfix(yylval.val.u.xval, v);
|
mpmovecfix(yylval.val.u.xval, v);
|
||||||
yylval.val.ctype = CTINT;
|
yylval.val.ctype = CTINT;
|
||||||
DBG("lex: codepoint literal\n");
|
DBG("lex: codepoint literal\n");
|
||||||
|
strcpy(litbuf, "string literal");
|
||||||
return LLITERAL;
|
return LLITERAL;
|
||||||
|
|
||||||
case '/':
|
case '/':
|
||||||
@ -1133,6 +1135,8 @@ ncu:
|
|||||||
}
|
}
|
||||||
yylval.val.ctype = CTINT;
|
yylval.val.ctype = CTINT;
|
||||||
DBG("lex: integer literal\n");
|
DBG("lex: integer literal\n");
|
||||||
|
strcpy(litbuf, "literal ");
|
||||||
|
strcat(litbuf, lexbuf);
|
||||||
return LLITERAL;
|
return LLITERAL;
|
||||||
|
|
||||||
casedot:
|
casedot:
|
||||||
@ -1205,6 +1209,8 @@ casei:
|
|||||||
}
|
}
|
||||||
yylval.val.ctype = CTCPLX;
|
yylval.val.ctype = CTCPLX;
|
||||||
DBG("lex: imaginary literal\n");
|
DBG("lex: imaginary literal\n");
|
||||||
|
strcpy(litbuf, "literal ");
|
||||||
|
strcat(litbuf, lexbuf);
|
||||||
return LLITERAL;
|
return LLITERAL;
|
||||||
|
|
||||||
caseout:
|
caseout:
|
||||||
@ -1219,6 +1225,8 @@ caseout:
|
|||||||
}
|
}
|
||||||
yylval.val.ctype = CTFLT;
|
yylval.val.ctype = CTFLT;
|
||||||
DBG("lex: floating literal\n");
|
DBG("lex: floating literal\n");
|
||||||
|
strcpy(litbuf, "literal ");
|
||||||
|
strcat(litbuf, lexbuf);
|
||||||
return LLITERAL;
|
return LLITERAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1859,6 +1867,12 @@ yytinit(void)
|
|||||||
for(i=0; yytname[i] != nil; i++) {
|
for(i=0; yytname[i] != nil; i++) {
|
||||||
s = yytname[i];
|
s = yytname[i];
|
||||||
|
|
||||||
|
if(strcmp(s, "LLITERAL") == 0) {
|
||||||
|
strcpy(litbuf, "literal");
|
||||||
|
yytname[i] = litbuf;
|
||||||
|
goto loop;
|
||||||
|
}
|
||||||
|
|
||||||
// apply yytfix if possible
|
// apply yytfix if possible
|
||||||
for(j=0; j<nelem(yytfix); j++) {
|
for(j=0; j<nelem(yytfix); j++) {
|
||||||
if(strcmp(s, yytfix[j].have) == 0) {
|
if(strcmp(s, yytfix[j].have) == 0) {
|
||||||
|
13
test/fixedbugs/bug349.go
Normal file
13
test/fixedbugs/bug349.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// errchk $G $D/$F.go
|
||||||
|
|
||||||
|
// Copyright 2011 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// issue 1192 - detail in error
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func foo() (a, b, c int) {
|
||||||
|
return 0, 1 2.01 // ERROR "unexpected literal 2.01"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user