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
d20ad1c7
Commit
d20ad1c7
authored
Jun 11, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: change -u to require imports to be marked safe
R=ken2 CC=golang-dev
https://golang.org/cl/1597043
parent
fe43325b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
3 deletions
+22
-3
export.c
src/cmd/gc/export.c
+4
-1
go.h
src/cmd/gc/go.h
+1
-0
go.y
src/cmd/gc/go.y
+12
-1
lex.c
src/cmd/gc/lex.c
+1
-0
typecheck.c
src/cmd/gc/typecheck.c
+4
-1
No files found.
src/cmd/gc/export.c
View file @
d20ad1c7
...
...
@@ -268,7 +268,10 @@ dumpexport(void)
packagequotes
=
1
;
Bprint
(
bout
,
"
\n
$$ // exports
\n
"
);
Bprint
(
bout
,
" package %s
\n
"
,
localpkg
->
name
);
Bprint
(
bout
,
" package %s"
,
localpkg
->
name
);
if
(
safemode
)
Bprint
(
bout
,
" safe"
);
Bprint
(
bout
,
"
\n
"
);
for
(
l
=
exportlist
;
l
;
l
=
l
->
next
)
{
lineno
=
l
->
n
->
lineno
;
...
...
src/cmd/gc/go.h
View file @
d20ad1c7
...
...
@@ -578,6 +578,7 @@ struct Io
int
peekc
;
int
peekc1
;
// second peekc for ...
char
*
cp
;
// used for content when bin==nil
int
importsafe
;
};
typedef
struct
Dlist
Dlist
;
...
...
src/cmd/gc/go.y
View file @
d20ad1c7
...
...
@@ -152,6 +152,7 @@ loadsys:
cannedimports("runtime.builtin", "package runtime\n\n$$\n\n");
else
cannedimports("runtime.builtin", runtimeimport);
curio.importsafe = 1;
}
import_package
import_there
...
...
@@ -236,10 +237,13 @@ import_here:
}
import_package
:
LPACKAGE
sym
';'
LPACKAGE
sym
import_safety
';'
{
importpkg
->
name
=
$
2
->
name
;
importpkg
->
direct
=
1
;
if
(
safemode
&&
!curio.importsafe)
yyerror
(
"cannot import unsafe package %Z"
,
importpkg
->
path
);
//
NOTE
(
rsc
):
This
is
no
longer
a
technical
restriction
:
//
the
6
g
tool
chain
would
work
just
fine
without
giving
...
...
@@ -250,6 +254,13 @@ import_package:
yyerror
(
"cannot import package main"
);
}
import_safety
:
|
LNAME
{
if
(
strcmp
($
1
->
name
,
"safe"
)
==
0
)
curio
.
importsafe
=
1
;
}
import_there
:
{
defercheckwidth
();
...
...
src/cmd/gc/lex.c
View file @
d20ad1c7
...
...
@@ -442,6 +442,7 @@ cannedimports(char *file, char *cp)
curio
.
infile
=
file
;
curio
.
cp
=
cp
;
curio
.
nlsemi
=
0
;
curio
.
importsafe
=
0
;
typecheckok
=
1
;
incannedimport
=
1
;
...
...
src/cmd/gc/typecheck.c
View file @
d20ad1c7
...
...
@@ -1191,7 +1191,10 @@ ret:
checkwidth
(
t
);
}
}
if
(
safemode
&&
isptrto
(
t
,
TANY
))
// TODO(rsc): should not need to check importpkg,
// but reflect mentions unsafe.Pointer.
if
(
safemode
&&
!
incannedimport
&&
!
importpkg
&&
isptrto
(
t
,
TANY
))
yyerror
(
"cannot use unsafe.Pointer"
);
evconst
(
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