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
c7ab3327
Commit
c7ab3327
authored
Dec 11, 2008
by
Ken Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restrict declarations of type map/chan/string
(they must be pointers) R=r OCL=21009 CL=21009
parent
73653841
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
2 deletions
+21
-2
src/cmd/gc/dcl.c
src/cmd/gc/dcl.c
+21
-2
No files found.
src/cmd/gc/dcl.c
View file @
c7ab3327
...
@@ -483,8 +483,18 @@ loop:
...
@@ -483,8 +483,18 @@ loop:
if
(
n
->
op
!=
ODCLFIELD
||
n
->
type
==
T
)
if
(
n
->
op
!=
ODCLFIELD
||
n
->
type
==
T
)
fatal
(
"stotype: oops %N
\n
"
,
n
);
fatal
(
"stotype: oops %N
\n
"
,
n
);
if
(
n
->
type
->
etype
==
TARRAY
&&
n
->
type
->
bound
<
0
)
switch
(
n
->
type
->
etype
)
{
case
TARRAY
:
if
(
n
->
type
->
bound
<
0
)
yyerror
(
"type of a structure field cannot be an open array"
);
yyerror
(
"type of a structure field cannot be an open array"
);
break
;
case
TCHAN
:
case
TMAP
:
case
TSTRING
:
yyerror
(
"%T can exist only in pointer form"
,
n
->
type
);
break
;
}
switch
(
n
->
val
.
ctype
)
{
switch
(
n
->
val
.
ctype
)
{
case
CTSTR
:
case
CTSTR
:
...
@@ -732,6 +742,15 @@ addvar(Node *n, Type *t, int ctxt)
...
@@ -732,6 +742,15 @@ addvar(Node *n, Type *t, int ctxt)
pushdcl
(
s
);
pushdcl
(
s
);
}
}
if
(
t
!=
T
)
{
switch
(
t
->
etype
)
{
case
TCHAN
:
case
TMAP
:
case
TSTRING
:
yyerror
(
"%T can exist only in pointer form"
,
t
);
}
}
redeclare
(
"variable"
,
s
);
redeclare
(
"variable"
,
s
);
s
->
vargen
=
gen
;
s
->
vargen
=
gen
;
s
->
oname
=
n
;
s
->
oname
=
n
;
...
...
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