Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
1fbbc69c
Commit
1fbbc69c
authored
Dec 08, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: Don't check for hidden fields on struct assignments.
From-SVN: r182143
parent
0ee1c847
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
48 additions
and
106 deletions
+48
-106
gcc/go/gofrontend/expressions.cc
+36
-1
gcc/go/gofrontend/types.cc
+1
-1
gcc/testsuite/go.test/test/assign.go
+11
-11
gcc/testsuite/go.test/test/fixedbugs/bug226.dir/x.go
+0
-9
gcc/testsuite/go.test/test/fixedbugs/bug226.dir/y.go
+0
-31
gcc/testsuite/go.test/test/fixedbugs/bug226.go
+0
-7
gcc/testsuite/go.test/test/fixedbugs/bug310.go
+0
-20
gcc/testsuite/go.test/test/fixedbugs/bug359.go
+0
-26
No files found.
gcc/go/gofrontend/expressions.cc
View file @
1fbbc69c
...
...
@@ -12817,7 +12817,22 @@ Composite_literal_expression::lower_struct(Gogo* gogo, Type* type)
Location
location
=
this
->
location
();
Struct_type
*
st
=
type
->
struct_type
();
if
(
this
->
vals_
==
NULL
||
!
this
->
has_keys_
)
return
new
Struct_construction_expression
(
type
,
this
->
vals_
,
location
);
{
if
(
this
->
vals_
!=
NULL
&&
!
this
->
vals_
->
empty
())
{
std
::
string
reason
;
if
(
type
->
has_hidden_fields
(
NULL
,
&
reason
))
{
if
(
reason
.
empty
())
error_at
(
this
->
location
(),
"implicit assignment of hidden field"
);
else
error_at
(
this
->
location
(),
"%s"
,
reason
.
c_str
());
}
}
return
new
Struct_construction_expression
(
type
,
this
->
vals_
,
location
);
}
size_t
field_count
=
st
->
field_count
();
std
::
vector
<
Expression
*>
vals
(
field_count
);
...
...
@@ -12964,6 +12979,26 @@ Composite_literal_expression::lower_struct(Gogo* gogo, Type* type)
return
Expression
::
make_error
(
location
);
}
if
(
type
->
named_type
()
!=
NULL
&&
type
->
named_type
()
->
named_object
()
->
package
()
!=
NULL
&&
Gogo
::
is_hidden_name
(
sf
->
field_name
()))
error_at
(
name_expr
->
location
(),
"assignment of unexported field %qs in %qs literal"
,
Gogo
::
message_name
(
sf
->
field_name
()).
c_str
(),
type
->
named_type
()
->
message_name
().
c_str
());
else
{
std
::
string
reason
;
if
(
sf
->
type
()
->
has_hidden_fields
(
NULL
,
&
reason
))
{
if
(
reason
.
empty
())
error_at
(
name_expr
->
location
(),
"implicit assignment of hidden field"
);
else
error_at
(
name_expr
->
location
(),
"%s"
,
reason
.
c_str
());
}
}
vals
[
index
]
=
val
;
}
...
...
gcc/go/gofrontend/types.cc
View file @
1fbbc69c
...
...
@@ -605,7 +605,7 @@ Type::are_assignable_check_hidden(const Type* lhs, const Type* rhs,
bool
Type
::
are_assignable
(
const
Type
*
lhs
,
const
Type
*
rhs
,
std
::
string
*
reason
)
{
return
Type
::
are_assignable_check_hidden
(
lhs
,
rhs
,
tru
e
,
reason
);
return
Type
::
are_assignable_check_hidden
(
lhs
,
rhs
,
fals
e
,
reason
);
}
// Like are_assignable but don't check for hidden fields.
...
...
gcc/testsuite/go.test/test/assign.go
View file @
1fbbc69c
...
...
@@ -16,38 +16,38 @@ type T struct {
func
main
()
{
{
var
x
,
y
sync
.
Mutex
x
=
y
// ERROR "assignment.*Mutex"
x
=
y
// ok
_
=
x
}
{
var
x
,
y
T
x
=
y
// ERROR "assignment.*Mutex"
x
=
y
// ok
_
=
x
}
{
var
x
,
y
[
2
]
sync
.
Mutex
x
=
y
// ERROR "assignment.*Mutex"
x
=
y
// ok
_
=
x
}
{
var
x
,
y
[
2
]
T
x
=
y
// ERROR "assignment.*Mutex"
x
=
y
// ok
_
=
x
}
{
x
:=
sync
.
Mutex
{
0
,
0
}
// ERROR "assignment.*Mutex"
x
:=
sync
.
Mutex
{
0
,
0
}
// ERROR "assignment.*Mutex"
_
=
x
}
{
x
:=
sync
.
Mutex
{
key
:
0
}
// ERROR "(unknown|assignment).*Mutex"
x
:=
sync
.
Mutex
{
key
:
0
}
// ERROR "(unknown|assignment).*Mutex"
_
=
x
}
{
x
:=
&
sync
.
Mutex
{}
// ok
var
y
sync
.
Mutex
// ok
y
=
*
x
// ERROR "assignment.*Mutex"
*
x
=
y
// ERROR "assignment.*Mutex"
x
:=
&
sync
.
Mutex
{}
// ok
var
y
sync
.
Mutex
// ok
y
=
*
x
// ok
*
x
=
y
// ok
_
=
x
_
=
y
}
}
}
gcc/testsuite/go.test/test/fixedbugs/bug226.dir/x.go
deleted
100644 → 0
View file @
0ee1c847
// 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
x
type
T
struct
{
x
,
Y
int
}
func
(
t
T
)
M
()
gcc/testsuite/go.test/test/fixedbugs/bug226.dir/y.go
deleted
100644 → 0
View file @
0ee1c847
// 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
y
import
"./x"
func
f
()
{
ok
:=
new
(
x
.
T
);
var
ok1
x
.
T
;
ok2
:=
&
ok1
;
ok3
:=
&
x
.
T
{};
ok4
:=
&
x
.
T
{
Y
:
2
};
_
=
x
.
T
{};
_
=
x
.
T
{
Y
:
2
};
ok1
.
M
();
bad1
:=
*
ok
;
// ERROR "assignment.*T"
bad2
:=
ok1
;
// ERROR "assignment.*T"
*
ok4
=
ok1
;
// ERROR "assignment.*T"
*
ok4
=
*
ok2
;
// ERROR "assignment.*T"
ok1
=
*
ok4
;
// ERROR "assignment.*T"
_
=
bad1
;
_
=
bad2
;
_
=
ok4
;
_
=
ok3
;
_
=
ok2
;
_
=
ok1
;
_
=
ok
;
}
gcc/testsuite/go.test/test/fixedbugs/bug226.go
deleted
100644 → 0
View file @
0ee1c847
// $G $D/$F.dir/x.go && errchk $G $D/$F.dir/y.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.
ignored
gcc/testsuite/go.test/test/fixedbugs/bug310.go
deleted
100644 → 0
View file @
0ee1c847
// errchk $G $D/$F.go
// Copyright 2010 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
p
import
(
"bytes"
"fmt"
)
type
t
int
func
main
()
{
_
=
t
.
bar
// ERROR "no method"
var
b
bytes
.
Buffer
fmt
.
Print
(
b
)
// ERROR "implicit assignment"
}
gcc/testsuite/go.test/test/fixedbugs/bug359.go
deleted
100644 → 0
View file @
0ee1c847
// errchk $G $D/$F.go
// Copyright 2011 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.
// issue 1910
// error on wrong line
package
main
import
"container/list"
type
Painting
struct
{
fragments
list
.
List
// private
}
func
(
p
Painting
)
Foo
()
{
for
e
:=
p
.
fragments
;
e
.
Front
()
!=
nil
;
{
// ERROR "unexported field|hidden field"
}
}
// from comment 4 of issue 1910
type
Foo
interface
{
Run
(
a
int
)
(
a
int
)
// ERROR "a redeclared|redefinition|previous"
}
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