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
f2b2ead4
Commit
f2b2ead4
authored
Dec 04, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: Give error for constant inverted slice range.
From-SVN: r194124
parent
44bd7f65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
gcc/go/gofrontend/expressions.cc
+12
-2
No files found.
gcc/go/gofrontend/expressions.cc
View file @
f2b2ead4
...
@@ -9770,8 +9770,10 @@ Array_index_expression::do_check_types(Gogo*)
...
@@ -9770,8 +9770,10 @@ Array_index_expression::do_check_types(Gogo*)
&&
lvalnc
.
to_int
(
&
lval
));
&&
lvalnc
.
to_int
(
&
lval
));
Numeric_constant
inc
;
Numeric_constant
inc
;
mpz_t
ival
;
mpz_t
ival
;
bool
ival_valid
=
false
;
if
(
this
->
start_
->
numeric_constant_value
(
&
inc
)
&&
inc
.
to_int
(
&
ival
))
if
(
this
->
start_
->
numeric_constant_value
(
&
inc
)
&&
inc
.
to_int
(
&
ival
))
{
{
ival_valid
=
true
;
if
(
mpz_sgn
(
ival
)
<
0
if
(
mpz_sgn
(
ival
)
<
0
||
mpz_sizeinbase
(
ival
,
2
)
>=
int_bits
||
mpz_sizeinbase
(
ival
,
2
)
>=
int_bits
||
(
lval_valid
||
(
lval_valid
...
@@ -9782,7 +9784,6 @@ Array_index_expression::do_check_types(Gogo*)
...
@@ -9782,7 +9784,6 @@ Array_index_expression::do_check_types(Gogo*)
error_at
(
this
->
start_
->
location
(),
"array index out of bounds"
);
error_at
(
this
->
start_
->
location
(),
"array index out of bounds"
);
this
->
set_is_error
();
this
->
set_is_error
();
}
}
mpz_clear
(
ival
);
}
}
if
(
this
->
end_
!=
NULL
&&
!
this
->
end_
->
is_nil_expression
())
if
(
this
->
end_
!=
NULL
&&
!
this
->
end_
->
is_nil_expression
())
{
{
...
@@ -9797,9 +9798,13 @@ Array_index_expression::do_check_types(Gogo*)
...
@@ -9797,9 +9798,13 @@ Array_index_expression::do_check_types(Gogo*)
error_at
(
this
->
end_
->
location
(),
"array index out of bounds"
);
error_at
(
this
->
end_
->
location
(),
"array index out of bounds"
);
this
->
set_is_error
();
this
->
set_is_error
();
}
}
else
if
(
ival_valid
&&
mpz_cmp
(
ival
,
eval
)
>
0
)
this
->
report_error
(
_
(
"inverted slice range"
));
mpz_clear
(
eval
);
mpz_clear
(
eval
);
}
}
}
}
if
(
ival_valid
)
mpz_clear
(
ival
);
if
(
lval_valid
)
if
(
lval_valid
)
mpz_clear
(
lval
);
mpz_clear
(
lval
);
...
@@ -10180,15 +10185,16 @@ String_index_expression::do_check_types(Gogo*)
...
@@ -10180,15 +10185,16 @@ String_index_expression::do_check_types(Gogo*)
Numeric_constant
inc
;
Numeric_constant
inc
;
mpz_t
ival
;
mpz_t
ival
;
bool
ival_valid
=
false
;
if
(
this
->
start_
->
numeric_constant_value
(
&
inc
)
&&
inc
.
to_int
(
&
ival
))
if
(
this
->
start_
->
numeric_constant_value
(
&
inc
)
&&
inc
.
to_int
(
&
ival
))
{
{
ival_valid
=
true
;
if
(
mpz_sgn
(
ival
)
<
0
if
(
mpz_sgn
(
ival
)
<
0
||
(
sval_valid
&&
mpz_cmp_ui
(
ival
,
sval
.
length
())
>=
0
))
||
(
sval_valid
&&
mpz_cmp_ui
(
ival
,
sval
.
length
())
>=
0
))
{
{
error_at
(
this
->
start_
->
location
(),
"string index out of bounds"
);
error_at
(
this
->
start_
->
location
(),
"string index out of bounds"
);
this
->
set_is_error
();
this
->
set_is_error
();
}
}
mpz_clear
(
ival
);
}
}
if
(
this
->
end_
!=
NULL
&&
!
this
->
end_
->
is_nil_expression
())
if
(
this
->
end_
!=
NULL
&&
!
this
->
end_
->
is_nil_expression
())
{
{
...
@@ -10202,9 +10208,13 @@ String_index_expression::do_check_types(Gogo*)
...
@@ -10202,9 +10208,13 @@ String_index_expression::do_check_types(Gogo*)
error_at
(
this
->
end_
->
location
(),
"string index out of bounds"
);
error_at
(
this
->
end_
->
location
(),
"string index out of bounds"
);
this
->
set_is_error
();
this
->
set_is_error
();
}
}
else
if
(
ival_valid
&&
mpz_cmp
(
ival
,
eval
)
>
0
)
this
->
report_error
(
_
(
"inverted slice range"
));
mpz_clear
(
eval
);
mpz_clear
(
eval
);
}
}
}
}
if
(
ival_valid
)
mpz_clear
(
ival
);
}
}
// Get a tree for a string index.
// Get a tree for a string index.
...
...
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