mirror of
https://github.com/golang/go
synced 2024-11-11 20:50:23 -07:00
cmd/gc: put 'not used' message on correct line
Fixes #4663. R=ken2 CC=golang-dev https://golang.org/cl/7235081
This commit is contained in:
parent
79a16a3b70
commit
e2711cb202
@ -405,6 +405,20 @@ simple_stmt:
|
||||
expr
|
||||
{
|
||||
$$ = $1;
|
||||
|
||||
// These nodes do not carry line numbers.
|
||||
// Since a bare name used as an expression is an error,
|
||||
// introduce a wrapper node to give the correct line.
|
||||
switch($$->op) {
|
||||
case ONAME:
|
||||
case ONONAME:
|
||||
case OTYPE:
|
||||
case OPACK:
|
||||
case OLITERAL:
|
||||
$$ = nod(OPAREN, $$, N);
|
||||
$$->implicit = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
| expr LASOP expr
|
||||
{
|
||||
@ -989,6 +1003,7 @@ bare_complitexpr:
|
||||
case OPACK:
|
||||
case OLITERAL:
|
||||
$$ = nod(OPAREN, $$, N);
|
||||
$$->implicit = 1;
|
||||
}
|
||||
}
|
||||
| '{' start_complit braced_keyval_list '}'
|
||||
|
1787
src/cmd/gc/y.tab.c
1787
src/cmd/gc/y.tab.c
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,24 @@
|
||||
/* A Bison parser, made by GNU Bison 2.5. */
|
||||
/* A Bison parser, made by GNU Bison 2.3. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA. */
|
||||
|
||||
/* As a special exception, you may create a larger work that contains
|
||||
part or all of the Bison parser skeleton and distribute that work
|
||||
@ -26,11 +29,10 @@
|
||||
special exception, which will cause the skeleton and the resulting
|
||||
Bison output files to be licensed under the GNU General Public
|
||||
License without this special exception.
|
||||
|
||||
|
||||
This special exception was added by the Free Software Foundation in
|
||||
version 2.2 of Bison. */
|
||||
|
||||
|
||||
/* Tokens. */
|
||||
#ifndef YYTOKENTYPE
|
||||
# define YYTOKENTYPE
|
||||
@ -144,28 +146,22 @@
|
||||
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 2068 of yacc.c */
|
||||
#line 28 "go.y"
|
||||
|
||||
{
|
||||
Node* node;
|
||||
NodeList* list;
|
||||
Type* type;
|
||||
Sym* sym;
|
||||
struct Val val;
|
||||
int i;
|
||||
|
||||
|
||||
|
||||
/* Line 2068 of yacc.c */
|
||||
#line 163 "y.tab.h"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
}
|
||||
/* Line 1529 of yacc.c. */
|
||||
#line 160 "y.tab.h"
|
||||
YYSTYPE;
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
#endif
|
||||
|
||||
extern YYSTYPE yylval;
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ func bla1() bool {
|
||||
|
||||
func bla5() bool {
|
||||
_ = 1
|
||||
false // ERROR "false not used|value computed is not used"
|
||||
false // ERROR "false evaluated but not used|value computed is not used"
|
||||
_ = 2
|
||||
return false
|
||||
}
|
||||
|
@ -14,5 +14,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
1 + 2 // ERROR "1 \+ 2 not used|value computed is not used"
|
||||
1 + 2 // ERROR "1 \+ 2 evaluated but not used|value computed is not used"
|
||||
}
|
||||
|
@ -47,8 +47,8 @@ func f() {
|
||||
defer println(1) // ok
|
||||
defer recover() // ok
|
||||
|
||||
int(0) // ERROR "int\(0\) not used"
|
||||
string([]byte("abc")) // ERROR "string\(\[\]byte literal\) not used"
|
||||
int(0) // ERROR "int\(0\) evaluated but not used"
|
||||
string([]byte("abc")) // ERROR "string\(\[\]byte literal\) evaluated but not used"
|
||||
|
||||
append(x, 1) // ERROR "not used"
|
||||
cap(x) // ERROR "not used"
|
||||
|
14
test/fixedbugs/issue4663.go
Normal file
14
test/fixedbugs/issue4663.go
Normal file
@ -0,0 +1,14 @@
|
||||
// errorcheck
|
||||
|
||||
// Copyright 2013 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 4663.
|
||||
// Make sure 'not used' message is placed correctly.
|
||||
|
||||
package main
|
||||
|
||||
func a(b int) int64 {
|
||||
b // ERROR "not used"
|
||||
}
|
Loading…
Reference in New Issue
Block a user