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
8332d80e
Commit
8332d80e
authored
Dec 22, 2010
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Correctly handle tuple assignment to _ at global scope.
From-SVN: r168184
parent
0bfe3fa1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
14 deletions
+46
-14
gcc/go/gofrontend/parse.cc
+45
-14
gcc/go/gofrontend/parse.h
+1
-0
No files found.
gcc/go/gofrontend/parse.cc
View file @
8332d80e
...
@@ -1654,8 +1654,18 @@ Parse::init_vars_from_map(const Typed_identifier_list* vars, Type* type,
...
@@ -1654,8 +1654,18 @@ Parse::init_vars_from_map(const Typed_identifier_list* vars, Type* type,
if
(
!
this
->
gogo_
->
in_global_scope
())
if
(
!
this
->
gogo_
->
in_global_scope
())
this
->
gogo_
->
add_statement
(
s
);
this
->
gogo_
->
add_statement
(
s
);
else
else
if
(
!
val_no
->
is_sink
())
val_no
->
var_value
()
->
add_preinit_statement
(
s
);
val_no
->
var_value
()
->
add_preinit_statement
(
s
);
else
if
(
!
no
->
is_sink
())
no
->
var_value
()
->
add_preinit_statement
(
s
);
else
{
// Execute the map index expression just so that we can fail if
// the map is nil.
Named_object
*
dummy
=
this
->
create_dummy_global
(
Type
::
lookup_bool_type
(),
NULL
,
location
);
dummy
->
var_value
()
->
add_preinit_statement
(
s
);
}
return
true
;
return
true
;
}
}
...
@@ -1705,8 +1715,16 @@ Parse::init_vars_from_receive(const Typed_identifier_list* vars, Type* type,
...
@@ -1705,8 +1715,16 @@ Parse::init_vars_from_receive(const Typed_identifier_list* vars, Type* type,
if
(
!
this
->
gogo_
->
in_global_scope
())
if
(
!
this
->
gogo_
->
in_global_scope
())
this
->
gogo_
->
add_statement
(
s
);
this
->
gogo_
->
add_statement
(
s
);
else
else
if
(
!
val_no
->
is_sink
())
val_no
->
var_value
()
->
add_preinit_statement
(
s
);
val_no
->
var_value
()
->
add_preinit_statement
(
s
);
else
if
(
!
no
->
is_sink
())
no
->
var_value
()
->
add_preinit_statement
(
s
);
else
{
Named_object
*
dummy
=
this
->
create_dummy_global
(
Type
::
lookup_bool_type
(),
NULL
,
location
);
dummy
->
var_value
()
->
add_preinit_statement
(
s
);
}
return
true
;
return
true
;
}
}
...
@@ -1757,8 +1775,15 @@ Parse::init_vars_from_type_guard(const Typed_identifier_list* vars,
...
@@ -1757,8 +1775,15 @@ Parse::init_vars_from_type_guard(const Typed_identifier_list* vars,
if
(
!
this
->
gogo_
->
in_global_scope
())
if
(
!
this
->
gogo_
->
in_global_scope
())
this
->
gogo_
->
add_statement
(
s
);
this
->
gogo_
->
add_statement
(
s
);
else
else
if
(
!
val_no
->
is_sink
())
val_no
->
var_value
()
->
add_preinit_statement
(
s
);
val_no
->
var_value
()
->
add_preinit_statement
(
s
);
else
if
(
!
no
->
is_sink
())
no
->
var_value
()
->
add_preinit_statement
(
s
);
else
{
Named_object
*
dummy
=
this
->
create_dummy_global
(
type
,
NULL
,
location
);
dummy
->
var_value
()
->
add_preinit_statement
(
s
);
}
return
true
;
return
true
;
}
}
...
@@ -1780,17 +1805,7 @@ Parse::init_var(const Typed_identifier& tid, Type* type, Expression* init,
...
@@ -1780,17 +1805,7 @@ Parse::init_var(const Typed_identifier& tid, Type* type, Expression* init,
if
(
!
this
->
gogo_
->
in_global_scope
())
if
(
!
this
->
gogo_
->
in_global_scope
())
this
->
gogo_
->
add_statement
(
Statement
::
make_statement
(
init
));
this
->
gogo_
->
add_statement
(
Statement
::
make_statement
(
init
));
else
else
{
return
this
->
create_dummy_global
(
type
,
init
,
location
);
// Create a dummy global variable to force the
// initializer to be run in the right place.
Variable
*
var
=
new
Variable
(
type
,
init
,
true
,
false
,
false
,
location
);
static
int
count
;
char
buf
[
30
];
snprintf
(
buf
,
sizeof
buf
,
"_.%d"
,
count
);
++
count
;
return
this
->
gogo_
->
add_variable
(
buf
,
var
);
}
}
}
return
this
->
gogo_
->
add_sink
();
return
this
->
gogo_
->
add_sink
();
}
}
...
@@ -1818,6 +1833,22 @@ Parse::init_var(const Typed_identifier& tid, Type* type, Expression* init,
...
@@ -1818,6 +1833,22 @@ Parse::init_var(const Typed_identifier& tid, Type* type, Expression* init,
return
this
->
gogo_
->
add_variable
(
tid
.
name
(),
var
);
return
this
->
gogo_
->
add_variable
(
tid
.
name
(),
var
);
}
}
// Create a dummy global variable to force an initializer to be run in
// the right place. This is used when a sink variable is initialized
// at global scope.
Named_object
*
Parse
::
create_dummy_global
(
Type
*
type
,
Expression
*
init
,
source_location
location
)
{
Variable
*
var
=
new
Variable
(
type
,
init
,
true
,
false
,
false
,
location
);
static
int
count
;
char
buf
[
30
];
snprintf
(
buf
,
sizeof
buf
,
"_.%d"
,
count
);
++
count
;
return
this
->
gogo_
->
add_variable
(
buf
,
var
);
}
// SimpleVarDecl = identifier ":=" Expression .
// SimpleVarDecl = identifier ":=" Expression .
// We've already seen the identifier.
// We've already seen the identifier.
...
...
gcc/go/gofrontend/parse.h
View file @
8332d80e
...
@@ -197,6 +197,7 @@ class Parse
...
@@ -197,6 +197,7 @@ class Parse
source_location
);
source_location
);
Named_object
*
init_var
(
const
Typed_identifier
&
,
Type
*
,
Expression
*
,
Named_object
*
init_var
(
const
Typed_identifier
&
,
Type
*
,
Expression
*
,
bool
is_coloneq
,
bool
type_from_init
,
bool
*
is_new
);
bool
is_coloneq
,
bool
type_from_init
,
bool
*
is_new
);
Named_object
*
create_dummy_global
(
Type
*
,
Expression
*
,
source_location
);
void
simple_var_decl_or_assignment
(
const
std
::
string
&
,
source_location
,
void
simple_var_decl_or_assignment
(
const
std
::
string
&
,
source_location
,
Range_clause
*
,
Type_switch
*
);
Range_clause
*
,
Type_switch
*
);
void
function_decl
();
void
function_decl
();
...
...
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