Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
6c2738eb
Commit
6c2738eb
authored
Aug 07, 2009
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug181 - type T *struct { T } is an invalid embedded type
R=ken OCL=32886 CL=32886
parent
99eca57d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
2 deletions
+22
-2
dcl.c
src/cmd/gc/dcl.c
+3
-1
go.h
src/cmd/gc/go.h
+1
-0
walk.c
src/cmd/gc/walk.c
+7
-1
bug181.go
test/fixedbugs/bug181.go
+11
-0
No files found.
src/cmd/gc/dcl.c
View file @
6c2738eb
...
...
@@ -900,8 +900,10 @@ stotype(NodeList *l, int et, Type **t)
t1
=
n
->
type
;
if
(
t1
->
sym
==
S
&&
isptr
[
t1
->
etype
])
t1
=
t1
->
type
;
if
(
t1
!=
T
&&
isptr
[
t1
->
etype
])
if
(
isptr
[
t1
->
etype
])
yyerror
(
"embedded type cannot be a pointer"
);
else
if
(
t1
->
etype
==
TFORW
&&
t1
->
embedlineno
==
0
)
t1
->
embedlineno
=
lineno
;
}
}
...
...
src/cmd/gc/go.h
View file @
6c2738eb
...
...
@@ -175,6 +175,7 @@ struct Type
int32
bound
;
// negative is dynamic array
int32
maplineno
;
// first use of TFORW as map key
int32
embedlineno
;
// first use of TFORW as embedded type
};
#define T ((Type*)0)
...
...
src/cmd/gc/walk.c
View file @
6c2738eb
...
...
@@ -111,7 +111,7 @@ walkdeflist(NodeList *l)
void
walkdef
(
Node
*
n
)
{
int
lno
,
maplineno
;
int
lno
,
maplineno
,
embedlineno
;
NodeList
*
init
;
Node
*
e
;
Type
*
t
;
...
...
@@ -210,6 +210,7 @@ walkdef(Node *n)
// copy new type and clear fields
// that don't come along
maplineno
=
n
->
type
->
maplineno
;
embedlineno
=
n
->
type
->
embedlineno
;
*
n
->
type
=
*
t
;
t
=
n
->
type
;
t
->
sym
=
n
->
sym
;
...
...
@@ -226,6 +227,11 @@ walkdef(Node *n)
lineno
=
maplineno
;
maptype
(
n
->
type
,
types
[
TBOOL
]);
}
if
(
embedlineno
)
{
lineno
=
embedlineno
;
if
(
isptr
[
t
->
etype
])
yyerror
(
"embedded type cannot be a pointer"
);
}
break
;
}
...
...
test/fixedbugs/bug181.go
0 → 100644
View file @
6c2738eb
// errchk $G $D/$F.go
// Copyright 2009 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.
package
main
type
T
*
struct
{
T
;
// ERROR "embed.*pointer"
}
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