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
5aac5cb2
Commit
5aac5cb2
authored
Dec 17, 2013
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: Use backend interface for runtime errors.
From-SVN: r206067
parent
bd925c50
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
34 deletions
+26
-34
gcc/go/gofrontend/expressions.cc
+12
-9
gcc/go/gofrontend/gogo-tree.cc
+0
-24
gcc/go/gofrontend/gogo.cc
+13
-0
gcc/go/gofrontend/gogo.h
+1
-1
No files found.
gcc/go/gofrontend/expressions.cc
View file @
5aac5cb2
...
...
@@ -4305,8 +4305,9 @@ Unary_expression::do_get_tree(Translate_context* context)
expr
,
fold_convert
(
TREE_TYPE
(
expr
),
null_pointer_node
));
tree
crash
=
gogo
->
runtime_error
(
RUNTIME_ERROR_NIL_DEREFERENCE
,
loc
);
Expression
*
crash_expr
=
gogo
->
runtime_error
(
RUNTIME_ERROR_NIL_DEREFERENCE
,
loc
);
tree
crash
=
crash_expr
->
get_tree
(
context
);
expr
=
fold_build2_loc
(
loc
.
gcc_location
(),
COMPOUND_EXPR
,
TREE_TYPE
(
expr
),
build3
(
COND_EXPR
,
void_type_node
,
...
...
@@ -6183,9 +6184,9 @@ Binary_expression::do_get_tree(Translate_context* context)
// __go_runtime_error(RUNTIME_ERROR_DIVISION_BY_ZERO), 0
int
errcode
=
RUNTIME_ERROR_DIVISION_BY_ZERO
;
Expression
*
crash
=
gogo
->
runtime_error
(
errcode
,
this
->
location
());
tree
panic
=
fold_build2_loc
(
gccloc
,
COMPOUND_EXPR
,
TREE_TYPE
(
ret
),
gogo
->
runtime_error
(
errcode
,
this
->
location
()),
crash
->
get_tree
(
context
),
fold_convert_loc
(
gccloc
,
TREE_TYPE
(
ret
),
integer_zero_node
));
...
...
@@ -6975,8 +6976,9 @@ Bound_method_expression::do_get_tree(Translate_context* context)
if
(
nil_check
!=
NULL
)
{
tree
nil_check_tree
=
nil_check
->
get_tree
(
context
);
tree
crash
=
Expression
*
crash_expr
=
context
->
gogo
()
->
runtime_error
(
RUNTIME_ERROR_NIL_DEREFERENCE
,
loc
);
tree
crash
=
crash_expr
->
get_tree
(
context
);
if
(
ret_tree
==
error_mark_node
||
nil_check_tree
==
error_mark_node
||
crash
==
error_mark_node
)
...
...
@@ -10715,7 +10717,7 @@ Array_index_expression::do_get_tree(Translate_context* context)
:
(
this
->
end_
==
NULL
?
RUNTIME_ERROR_SLICE_INDEX_OUT_OF_BOUNDS
:
RUNTIME_ERROR_SLICE_SLICE_OUT_OF_BOUNDS
));
tree
crash
=
gogo
->
runtime_error
(
code
,
loc
);
tree
crash
=
gogo
->
runtime_error
(
code
,
loc
)
->
get_tree
(
context
)
;
if
(
this
->
end_
==
NULL
)
{
...
...
@@ -11089,7 +11091,7 @@ String_index_expression::do_get_tree(Translate_context* context)
int
code
=
(
this
->
end_
==
NULL
?
RUNTIME_ERROR_STRING_INDEX_OUT_OF_BOUNDS
:
RUNTIME_ERROR_STRING_SLICE_OUT_OF_BOUNDS
);
tree
crash
=
context
->
gogo
()
->
runtime_error
(
code
,
loc
);
tree
crash
=
context
->
gogo
()
->
runtime_error
(
code
,
loc
)
->
get_tree
(
context
)
;
if
(
this
->
end_
==
NULL
)
{
...
...
@@ -11879,8 +11881,9 @@ Interface_field_reference_expression::do_get_tree(Translate_context* context)
this
->
expr_
,
Expression
::
make_nil
(
loc
),
loc
);
tree
crash
=
context
->
gogo
()
->
runtime_error
(
RUNTIME_ERROR_NIL_DEREFERENCE
,
loc
);
Expression
*
crash_expr
=
context
->
gogo
()
->
runtime_error
(
RUNTIME_ERROR_NIL_DEREFERENCE
,
loc
);
tree
crash
=
crash_expr
->
get_tree
(
context
);
if
(
closure_tree
==
error_mark_node
||
nil_check_tree
==
error_mark_node
||
crash
==
error_mark_node
)
...
...
gcc/go/gofrontend/gogo-tree.cc
View file @
5aac5cb2
...
...
@@ -2252,30 +2252,6 @@ Gogo::call_builtin(tree* pdecl, Location location, const char* name,
return
ret
;
}
// Build a call to the runtime error function.
tree
Gogo
::
runtime_error
(
int
code
,
Location
location
)
{
Type
*
int32_type
=
Type
::
lookup_integer_type
(
"int32"
);
tree
int32_type_tree
=
type_to_tree
(
int32_type
->
get_backend
(
this
));
static
tree
runtime_error_fndecl
;
tree
ret
=
Gogo
::
call_builtin
(
&
runtime_error_fndecl
,
location
,
"__go_runtime_error"
,
1
,
void_type_node
,
int32_type_tree
,
build_int_cst
(
int32_type_tree
,
code
));
if
(
ret
==
error_mark_node
)
return
error_mark_node
;
// The runtime error function panics and does not return.
TREE_NOTHROW
(
runtime_error_fndecl
)
=
0
;
TREE_THIS_VOLATILE
(
runtime_error_fndecl
)
=
1
;
return
ret
;
}
// Return a tree for receiving a value of type TYPE_TREE on CHANNEL.
// TYPE_DESCRIPTOR_TREE is the channel's type descriptor. This does a
// blocking receive and returns the value read from the channel.
...
...
gcc/go/gofrontend/gogo.cc
View file @
5aac5cb2
...
...
@@ -3060,6 +3060,19 @@ Gogo::build_recover_thunks()
this
->
traverse
(
&
build_recover_thunks
);
}
// Build a call to the runtime error function.
Expression
*
Gogo
::
runtime_error
(
int
code
,
Location
location
)
{
Type
*
int32_type
=
Type
::
lookup_integer_type
(
"int32"
);
mpz_t
val
;
mpz_init_set_ui
(
val
,
code
);
Expression
*
code_expr
=
Expression
::
make_integer
(
&
val
,
int32_type
,
location
);
mpz_clear
(
val
);
return
Runtime
::
make_call
(
Runtime
::
RUNTIME_ERROR
,
location
,
1
,
code_expr
);
}
// Look for named types to see whether we need to create an interface
// method table.
...
...
gcc/go/gofrontend/gogo.h
View file @
5aac5cb2
...
...
@@ -576,7 +576,7 @@ class Gogo
tree
rettype
,
...);
// Build a call to the runtime error function.
tree
Expression
*
runtime_error
(
int
code
,
Location
);
// Build a builtin struct with a list of fields.
...
...
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