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
bf899bef
Commit
bf899bef
authored
Jul 26, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: disallow [...][...]int{{1,2,3}}
Fixes #1600. R=ken2 CC=golang-dev
https://golang.org/cl/4819045
parent
e5437ab0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
go.h
src/cmd/gc/go.h
+1
-0
typecheck.c
src/cmd/gc/typecheck.c
+4
-7
ddd1.go
test/ddd1.go
+2
-0
No files found.
src/cmd/gc/go.h
View file @
bf899bef
...
@@ -531,6 +531,7 @@ enum
...
@@ -531,6 +531,7 @@ enum
Eindir
=
1
<<
8
,
// indirecting through expression
Eindir
=
1
<<
8
,
// indirecting through expression
Eaddr
=
1
<<
9
,
// taking address of expression
Eaddr
=
1
<<
9
,
// taking address of expression
Eproc
=
1
<<
10
,
// inside a go statement
Eproc
=
1
<<
10
,
// inside a go statement
Ecomplit
=
1
<<
11
,
// type in composite literal
};
};
#define BITS 5
#define BITS 5
...
...
src/cmd/gc/typecheck.c
View file @
bf899bef
...
@@ -239,6 +239,8 @@ reswitch:
...
@@ -239,6 +239,8 @@ reswitch:
t
->
bound
=
-
1
;
// slice
t
->
bound
=
-
1
;
// slice
}
else
if
(
l
->
op
==
ODDD
)
{
}
else
if
(
l
->
op
==
ODDD
)
{
t
->
bound
=
-
100
;
// to be filled in
t
->
bound
=
-
100
;
// to be filled in
if
(
!
(
top
&
Ecomplit
))
yyerror
(
"use of [...] array outside of array literal"
);
}
else
{
}
else
{
l
=
typecheck
(
&
n
->
left
,
Erv
);
l
=
typecheck
(
&
n
->
left
,
Erv
);
switch
(
consttype
(
l
))
{
switch
(
consttype
(
l
))
{
...
@@ -1342,11 +1344,6 @@ ret:
...
@@ -1342,11 +1344,6 @@ ret:
case
TNIL
:
case
TNIL
:
case
TBLANK
:
case
TBLANK
:
break
;
break
;
case
TARRAY
:
if
(
t
->
bound
==
-
100
)
{
yyerror
(
"use of [...] array outside of array literal"
);
t
->
bound
=
1
;
}
default:
default:
checkwidth
(
t
);
checkwidth
(
t
);
}
}
...
@@ -1971,7 +1968,7 @@ typecheckcomplit(Node **np)
...
@@ -1971,7 +1968,7 @@ typecheckcomplit(Node **np)
}
}
setlineno
(
n
->
right
);
setlineno
(
n
->
right
);
l
=
typecheck
(
&
n
->
right
/* sic */
,
Etype
);
l
=
typecheck
(
&
n
->
right
/* sic */
,
Etype
|
Ecomplit
);
if
((
t
=
l
->
type
)
==
T
)
if
((
t
=
l
->
type
)
==
T
)
goto
error
;
goto
error
;
nerr
=
nerrors
;
nerr
=
nerrors
;
...
@@ -2039,7 +2036,7 @@ typecheckcomplit(Node **np)
...
@@ -2039,7 +2036,7 @@ typecheckcomplit(Node **np)
l
->
right
->
right
=
typenod
(
pushtype
);
l
->
right
->
right
=
typenod
(
pushtype
);
typecheck
(
&
l
->
right
,
Erv
);
typecheck
(
&
l
->
right
,
Erv
);
defaultlit
(
&
l
->
right
,
t
->
type
);
defaultlit
(
&
l
->
right
,
t
->
type
);
l
->
right
=
assignconv
(
l
->
right
,
t
->
type
,
"array
index
"
);
l
->
right
=
assignconv
(
l
->
right
,
t
->
type
,
"array
element
"
);
}
}
if
(
t
->
bound
==
-
100
)
if
(
t
->
bound
==
-
100
)
t
->
bound
=
len
;
t
->
bound
=
len
;
...
...
test/ddd1.go
View file @
bf899bef
...
@@ -44,4 +44,6 @@ func bad(args ...int) {
...
@@ -44,4 +44,6 @@ func bad(args ...int) {
_
=
unsafe
.
Pointer
(
&
x
...
)
// ERROR "[.][.][.]"
_
=
unsafe
.
Pointer
(
&
x
...
)
// ERROR "[.][.][.]"
_
=
unsafe
.
Sizeof
(
x
...
)
// ERROR "[.][.][.]"
_
=
unsafe
.
Sizeof
(
x
...
)
// ERROR "[.][.][.]"
_
=
[
...
]
byte
(
"foo"
)
// ERROR "[.][.][.]"
_
=
[
...
]
byte
(
"foo"
)
// ERROR "[.][.][.]"
_
=
[
...
][
...
]
int
{{
1
,
2
,
3
},{
4
,
5
,
6
}}
// ERROR "[.][.][.]"
}
}
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