Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
5c52404a
Commit
5c52404a
authored
Feb 09, 2012
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: implicit type bug fix in export data
TBR=lvd CC=golang-dev
https://golang.org/cl/5644064
parent
29df9373
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
757 additions
and
199 deletions
+757
-199
src/cmd/gc/fmt.c
src/cmd/gc/fmt.c
+6
-4
src/cmd/gc/go.h
src/cmd/gc/go.h
+1
-8
src/cmd/gc/go.y
src/cmd/gc/go.y
+1
-1
src/cmd/gc/typecheck.c
src/cmd/gc/typecheck.c
+4
-3
src/cmd/gc/y.tab.c
src/cmd/gc/y.tab.c
+699
-162
src/cmd/gc/y.tab.h
src/cmd/gc/y.tab.h
+25
-19
test/fixedbugs/bug392.dir/one.go
test/fixedbugs/bug392.dir/one.go
+3
-1
test/fixedbugs/bug392.dir/three.go
test/fixedbugs/bug392.dir/three.go
+13
-0
test/fixedbugs/bug392.dir/two.go
test/fixedbugs/bug392.dir/two.go
+4
-0
test/fixedbugs/bug392.go
test/fixedbugs/bug392.go
+1
-1
No files found.
src/cmd/gc/fmt.c
View file @
5c52404a
...
@@ -1058,7 +1058,7 @@ exprfmt(Fmt *f, Node *n, int prec)
...
@@ -1058,7 +1058,7 @@ exprfmt(Fmt *f, Node *n, int prec)
NodeList
*
l
;
NodeList
*
l
;
Type
*
t
;
Type
*
t
;
while
(
n
&&
n
->
implicit
)
while
(
n
&&
n
->
implicit
&&
(
n
->
op
==
OIND
||
n
->
op
==
OADDR
)
)
n
=
n
->
left
;
n
=
n
->
left
;
if
(
n
==
N
)
if
(
n
==
N
)
...
@@ -1160,13 +1160,13 @@ exprfmt(Fmt *f, Node *n, int prec)
...
@@ -1160,13 +1160,13 @@ exprfmt(Fmt *f, Node *n, int prec)
return
fmtprint
(
f
,
"%N{ %,H }"
,
n
->
right
,
n
->
list
);
return
fmtprint
(
f
,
"%N{ %,H }"
,
n
->
right
,
n
->
list
);
case
OPTRLIT
:
case
OPTRLIT
:
if
(
fmtmode
==
FExp
&&
n
->
left
->
right
->
implicit
==
Implicit
)
if
(
fmtmode
==
FExp
&&
n
->
left
->
implicit
)
return
fmtprint
(
f
,
"%N"
,
n
->
left
);
return
fmtprint
(
f
,
"%N"
,
n
->
left
);
return
fmtprint
(
f
,
"&%N"
,
n
->
left
);
return
fmtprint
(
f
,
"&%N"
,
n
->
left
);
case
OSTRUCTLIT
:
case
OSTRUCTLIT
:
if
(
fmtmode
==
FExp
)
{
// requires special handling of field names
if
(
fmtmode
==
FExp
)
{
// requires special handling of field names
if
(
n
->
right
->
implicit
==
I
mplicit
)
if
(
n
->
i
mplicit
)
fmtstrcpy
(
f
,
"{"
);
fmtstrcpy
(
f
,
"{"
);
else
else
fmtprint
(
f
,
"%T{"
,
n
->
type
);
fmtprint
(
f
,
"%T{"
,
n
->
type
);
...
@@ -1194,6 +1194,8 @@ exprfmt(Fmt *f, Node *n, int prec)
...
@@ -1194,6 +1194,8 @@ exprfmt(Fmt *f, Node *n, int prec)
case
OMAPLIT
:
case
OMAPLIT
:
if
(
fmtmode
==
FErr
)
if
(
fmtmode
==
FErr
)
return
fmtprint
(
f
,
"%T literal"
,
n
->
type
);
return
fmtprint
(
f
,
"%T literal"
,
n
->
type
);
if
(
fmtmode
==
FExp
&&
n
->
implicit
)
return
fmtprint
(
f
,
"{ %,H }"
,
n
->
list
);
return
fmtprint
(
f
,
"%T{ %,H }"
,
n
->
type
,
n
->
list
);
return
fmtprint
(
f
,
"%T{ %,H }"
,
n
->
type
,
n
->
list
);
case
OKEY
:
case
OKEY
:
...
...
src/cmd/gc/go.h
View file @
5c52404a
...
@@ -215,13 +215,6 @@ enum
...
@@ -215,13 +215,6 @@ enum
EscNever
,
EscNever
,
};
};
enum
{
Explicit
,
Implicit
,
// don't print in output
ImplPtr
,
// OIND added by &T{ ... } literal
};
struct
Node
struct
Node
{
{
// Tree structure.
// Tree structure.
...
@@ -257,7 +250,7 @@ struct Node
...
@@ -257,7 +250,7 @@ struct Node
uchar
used
;
uchar
used
;
uchar
isddd
;
uchar
isddd
;
uchar
readonly
;
uchar
readonly
;
uchar
implicit
;
// Explicit, Implicit, ImplPtr.
uchar
implicit
;
uchar
addrtaken
;
// address taken, even if not moved to heap
uchar
addrtaken
;
// address taken, even if not moved to heap
uchar
dupok
;
// duplicate definitions ok (for func)
uchar
dupok
;
// duplicate definitions ok (for func)
...
...
src/cmd/gc/go.y
View file @
5c52404a
...
@@ -808,7 +808,7 @@ uexpr:
...
@@ -808,7 +808,7 @@ uexpr:
//
Special
case
for
&
T
{...}:
turn
into
(*
T
){...}.
//
Special
case
for
&
T
{...}:
turn
into
(*
T
){...}.
$$
=
$
2
;
$$
=
$
2
;
$$->
right
=
nod
(
OIND
,
$$->
right
,
N
);
$$->
right
=
nod
(
OIND
,
$$->
right
,
N
);
$$->
right
->
implicit
=
ImplPtr
;
$$->
right
->
implicit
=
1
;
}
else
{
}
else
{
$$
=
nod
(
OADDR
,
$
2
,
N
);
$$
=
nod
(
OADDR
,
$
2
,
N
);
}
}
...
...
src/cmd/gc/typecheck.c
View file @
5c52404a
...
@@ -2008,7 +2008,8 @@ pushtype(Node *n, Type *t)
...
@@ -2008,7 +2008,8 @@ pushtype(Node *n, Type *t)
if
(
n
->
right
==
N
)
{
if
(
n
->
right
==
N
)
{
n
->
right
=
typenod
(
t
);
n
->
right
=
typenod
(
t
);
n
->
right
->
implicit
=
1
;
n
->
implicit
=
1
;
// don't print
n
->
right
->
implicit
=
1
;
// * is okay
}
}
else
if
(
debug
[
's'
])
{
else
if
(
debug
[
's'
])
{
typecheck
(
&
n
->
right
,
Etype
);
typecheck
(
&
n
->
right
,
Etype
);
...
@@ -2048,8 +2049,8 @@ typecheckcomplit(Node **np)
...
@@ -2048,8 +2049,8 @@ typecheckcomplit(Node **np)
if
(
isptr
[
t
->
etype
])
{
if
(
isptr
[
t
->
etype
])
{
// For better or worse, we don't allow pointers as the composite literal type,
// For better or worse, we don't allow pointers as the composite literal type,
// except when using the &T syntax, which sets implicit
to ImplPtr
.
// except when using the &T syntax, which sets implicit
on the OIND
.
if
(
n
->
right
->
implicit
==
Ex
plicit
)
{
if
(
!
n
->
right
->
im
plicit
)
{
yyerror
(
"invalid pointer type %T for composite literal (use &%T instead)"
,
t
,
t
->
type
);
yyerror
(
"invalid pointer type %T for composite literal (use &%T instead)"
,
t
,
t
->
type
);
goto
error
;
goto
error
;
}
}
...
...
src/cmd/gc/y.tab.c
View file @
5c52404a
This diff is collapsed.
Click to expand it.
src/cmd/gc/y.tab.h
View file @
5c52404a
/* A Bison parser, made by GNU Bison 2.3. */
/*
Skeleton interface for Bison's Yacc-like parsers in C
/*
A Bison parser, made by GNU Bison 2.4.1. */
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
/* 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.
Free Software Foundation, Inc.
This program is free software
;
you can redistribute it and/or modify
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
it under the terms of the GNU General Public License as published by
the Free Software Foundation
; either version 2, or (at your option)
the Free Software Foundation
, either version 3 of the License, or
any later version.
(at your option)
any later version.
This program is distributed in the hope that it will be useful,
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program. If not, see <http://www.gnu.org/licenses/>. */
Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA. */
/* As a special exception, you may create a larger work that contains
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
part or all of the Bison parser skeleton and distribute that work
...
@@ -29,10 +28,11 @@
...
@@ -29,10 +28,11 @@
special exception, which will cause the skeleton and the resulting
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
Bison output files to be licensed under the GNU General Public
License without this special exception.
License without this special exception.
This special exception was added by the Free Software Foundation in
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
version 2.2 of Bison. */
/* Tokens. */
/* Tokens. */
#ifndef YYTOKENTYPE
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
# define YYTOKENTYPE
...
@@ -146,22 +146,28 @@
...
@@ -146,22 +146,28 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef
union
YYSTYPE
typedef
union
YYSTYPE
#line 28 "go.y"
{
{
/* Line 1676 of yacc.c */
#line 28 "go.y"
Node
*
node
;
Node
*
node
;
NodeList
*
list
;
NodeList
*
list
;
Type
*
type
;
Type
*
type
;
Sym
*
sym
;
Sym
*
sym
;
struct
Val
val
;
struct
Val
val
;
int
i
;
int
i
;
}
/* Line 1529 of yacc.c. */
#line 160 "y.tab.h"
YYSTYPE
;
/* Line 1676 of yacc.c */
#line 165 "y.tab.h"
}
YYSTYPE
;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE
/* obsolescent; will be withdrawn */
# define yystype YYSTYPE
/* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
#endif
extern
YYSTYPE
yylval
;
extern
YYSTYPE
yylval
;
test/fixedbugs/bug392.dir/one.go
View file @
5c52404a
...
@@ -36,6 +36,8 @@ func F6(S int) *U {
...
@@ -36,6 +36,8 @@ func F6(S int) *U {
return
&
U
{{
S
,
S
}}
return
&
U
{{
S
,
S
}}
}
}
// Bug in the fix.
type
PB
struct
{
x
int
}
func
(
t
*
PB
)
Reset
()
{
*
t
=
PB
{}
}
test/fixedbugs/bug392.dir/three.go
0 → 100644
View file @
5c52404a
// Copyright 2012 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.
// Use the functions in one.go so that the inlined
// forms get type-checked.
package
three
import
"./two"
var
x
=
two
.
F
()
var
v
=
two
.
V
test/fixedbugs/bug392.dir/two.go
View file @
5c52404a
...
@@ -19,3 +19,7 @@ func use() {
...
@@ -19,3 +19,7 @@ func use() {
t
.
M
()
t
.
M
()
t
.
MM
()
t
.
MM
()
}
}
var
V
=
[]
one
.
PB
{{},
{}}
func
F
()
*
one
.
PB
test/fixedbugs/bug392.go
View file @
5c52404a
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
// $G $D/$F.dir/one.go && $G $D/$F.dir/two.go
&& $G $D/$F.dir/three.go
// Copyright 2011 The Go Authors. All rights reserved.
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// Use of this source code is governed by a BSD-style
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment