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
c6cb303a
Commit
c6cb303a
authored
Aug 03, 2010
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc: bug299, bug300
R=ken2 CC=golang-dev
https://golang.org/cl/1731057
parent
b91c70ad
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
28 deletions
+74
-28
src/cmd/gc/go.h
src/cmd/gc/go.h
+1
-0
src/cmd/gc/go.y
src/cmd/gc/go.y
+32
-0
src/pkg/reflect/all_test.go
src/pkg/reflect/all_test.go
+8
-10
test/fixedbugs/bug299.go
test/fixedbugs/bug299.go
+27
-0
test/fixedbugs/bug300.go
test/fixedbugs/bug300.go
+6
-6
test/golden.out
test/golden.out
+0
-12
No files found.
src/cmd/gc/go.h
View file @
c6cb303a
...
...
@@ -209,6 +209,7 @@ struct Node
uchar
dodata
;
// compile literal assignment as data statement
uchar
used
;
uchar
isddd
;
uchar
paren
;
// was parenthesized
uchar
pun
;
// dont registerize variable ONAME
// most nodes
...
...
src/cmd/gc/go.y
View file @
c6cb303a
...
...
@@ -832,6 +832,7 @@ pexpr:
|
'('
expr_or_type
')'
{
$$
=
$
2
;
$$->
paren
++;
}
|
pexpr
'.'
'('
expr_or_type
')'
{
...
...
@@ -874,6 +875,8 @@ pexpr:
}
| pexpr '
{
' braced_keyval_list '
}
'
{
if($1->paren)
yyerror("cannot parenthesize type in composite literal");
// composite expression
$$ = nod(OCOMPLIT, N, $1);
$$->list = $3;
...
...
@@ -963,6 +966,7 @@ ntype:
| '
(
' ntype '
)
'
{
$$ = $2;
$$->paren++;
}
non_expr_type:
...
...
@@ -982,6 +986,7 @@ non_recvchantype:
| '
(
' ntype '
)
'
{
$$ = $2;
$$->paren++;
}
convtype:
...
...
@@ -1141,6 +1146,8 @@ fndcl:
yyerror("bad receiver in method");
break;
}
if(rcvr->right->paren || (rcvr->right->op == OIND && rcvr->right->left->paren))
yyerror("cannot parenthesize receiver type");
$$ = nod(ODCLFUNC, N, N);
$$->nname = methodname1(name, rcvr->right);
...
...
@@ -1273,12 +1280,32 @@ structdcl:
$1->val = $2;
$$ = list1($1);
}
| '
(
' embed '
)
' oliteral
{
$2->val = $4;
$$ = list1($2);
yyerror("cannot parenthesize embedded type");
}
| '
*
' embed oliteral
{
$2->right = nod(OIND, $2->right, N);
$2->val = $3;
$$ = list1($2);
}
| '
(
' '
*
' embed '
)
' oliteral
{
$3->right = nod(OIND, $3->right, N);
$3->val = $5;
$$ = list1($3);
yyerror("cannot parenthesize embedded type");
}
| '
*
' '
(
' embed '
)
' oliteral
{
$3->right = nod(OIND, $3->right, N);
$3->val = $5;
$$ = list1($3);
yyerror("cannot parenthesize embedded type");
}
packname:
LNAME
...
...
@@ -1319,6 +1346,11 @@ interfacedcl:
{
$$ = nod(ODCLFIELD, N, oldname($1));
}
| '
(
' packname '
)
'
{
$$ = nod(ODCLFIELD, N, oldname($2));
yyerror("cannot parenthesize embedded type");
}
indcl:
'
(
' oarg_type_list_ocomma '
)
' fnres
...
...
src/pkg/reflect/all_test.go
View file @
c6cb303a
...
...
@@ -170,33 +170,31 @@ var valueTests = []pair{
pair
{(
bool
)(
false
),
"true"
},
pair
{(
*
int8
)(
nil
),
"*int8(0)"
},
pair
{(
**
int8
)(
nil
),
"**int8(0)"
},
pair
{
([
5
]
int32
)
{},
"[5]int32{0, 0, 0, 0, 0}"
},
pair
{
[
5
]
int32
{},
"[5]int32{0, 0, 0, 0, 0}"
},
pair
{(
**
integer
)(
nil
),
"**reflect_test.integer(0)"
},
pair
{(
map
[
string
]
int32
)(
nil
),
"map[string] int32{<can't iterate on maps>}"
},
pair
{(
chan
<-
string
)(
nil
),
"chan<- string"
},
pair
{
(
struct
{
pair
{
struct
{
c
chan
*
int32
d
float32
}
)
{},
}{},
"struct { c chan *int32; d float32 }{chan *int32, 0}"
,
},
pair
{(
func
(
a
int8
,
b
int32
))(
nil
),
"func(int8, int32)(0)"
},
pair
{(
struct
{
c
func
(
chan
*
integer
,
*
int8
)
}){},
pair
{
struct
{
c
func
(
chan
*
integer
,
*
int8
)
}{},
"struct { c func(chan *reflect_test.integer, *int8) }{func(chan *reflect_test.integer, *int8)(0)}"
,
},
pair
{
(
struct
{
pair
{
struct
{
a
int8
b
int32
}
)
{},
}{},
"struct { a int8; b int32 }{0, 0}"
,
},
pair
{
(
struct
{
pair
{
struct
{
a
int8
b
int8
c
int32
}
)
{},
}{},
"struct { a int8; b int8; c int32 }{0, 0, 0}"
,
},
}
...
...
test/bugs/bug299.go
→
test/
fixed
bugs/bug299.go
View file @
c6cb303a
...
...
@@ -7,21 +7,21 @@
package
main
type
T
struct
{
//
accepted by both compilers,
legal according to spec
// legal according to spec
x
int
y
(
int
)
int
*
float
// not
accepted by both compilers, not
legal according to spec
(
complex
)
// ERROR "non-declaration|expected"
(
*
string
)
// ERROR "non-declaration|expected"
*
(
bool
)
// ERROR "non-declaration|expected"
// not legal according to spec
(
complex
)
// ERROR "non-declaration|expected
|parenthesize
"
(
*
string
)
// ERROR "non-declaration|expected
|parenthesize
"
*
(
bool
)
// ERROR "non-declaration|expected
|parenthesize
"
}
//
accepted by both compilers,
legal according to spec
// legal according to spec
func
(
p
T
)
m
()
{}
//
accepted by 6g, not accepted by gccgo,
not legal according to spec
func
(
p
(
T
))
f
()
{}
// ERROR "
expected
"
func
(
p
*
(
T
))
g
()
{}
// ERROR "
expected
"
func
(
p
(
*
T
))
h
()
{}
// ERROR "
expected
"
// not legal according to spec
func
(
p
(
T
))
f
()
{}
// ERROR "
parenthesize
"
func
(
p
*
(
T
))
g
()
{}
// ERROR "
parenthesize
"
func
(
p
(
*
T
))
h
()
{}
// ERROR "
parenthesize
"
test/bugs/bug300.go
→
test/
fixed
bugs/bug300.go
View file @
c6cb303a
...
...
@@ -20,10 +20,10 @@ func main() {
_
=
T
{}
// illegal composite literals: parentheses not allowed around literal type
_
=
(
struct
{}){}
// ERROR "xxx
"
_
=
([
42
]
int
){}
// ERROR "xxx
"
_
=
([
...
]
int
){}
// ERROR "xxx
"
_
=
([]
int
){}
// ERROR "xxx
"
_
=
(
map
[
int
]
int
){}
// ERROR "xxx
"
_
=
(
T
){}
// ERROR "xxx
"
_
=
(
struct
{}){}
// ERROR "parenthesize
"
_
=
([
42
]
int
){}
// ERROR "parenthesize
"
_
=
([
...
]
int
){}
// ERROR "parenthesize
"
_
=
([]
int
){}
// ERROR "parenthesize
"
_
=
(
map
[
int
]
int
){}
// ERROR "parenthesize
"
_
=
(
T
){}
// ERROR "parenthesize
"
}
test/golden.out
View file @
c6cb303a
...
...
@@ -177,15 +177,3 @@ panic PC=xxx
=========== bugs/bug260.go
FAIL
BUG: bug260 failed
=========== bugs/bug299.go
BUG: errchk: bugs/bug299.go:25: missing expected error: 'expected'
errchk: bugs/bug299.go:26: missing expected error: 'expected'
errchk: bugs/bug299.go:27: missing expected error: 'expected'
errchk: bugs/bug299.go: unmatched error messages:
==================================================
bugs/bug299.go:19: syntax error: unexpected }
==================================================
=========== bugs/bug300.go
BUG: errchk: command succeeded unexpectedly
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