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
fc24bee9
Commit
fc24bee9
authored
Mar 01, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: Fix unary ^ applied to typed signed integer constant.
From-SVN: r184681
parent
75c37a64
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
3 deletions
+22
-3
gcc/go/gofrontend/expressions.cc
+22
-3
No files found.
gcc/go/gofrontend/expressions.cc
View file @
fc24bee9
...
...
@@ -4300,14 +4300,23 @@ Unary_expression::eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val,
unsigned
HOST_WIDE_INT
*
phwi
=
new
unsigned
HOST_WIDE_INT
[
count
];
memset
(
phwi
,
0
,
count
*
sizeof
(
HOST_WIDE_INT
));
size_t
obits
=
utype
->
integer_type
()
->
bits
();
if
(
!
utype
->
integer_type
()
->
is_unsigned
()
&&
mpz_sgn
(
uval
)
<
0
)
{
mpz_t
adj
;
mpz_init_set_ui
(
adj
,
1
);
mpz_mul_2exp
(
adj
,
adj
,
obits
);
mpz_add
(
uval
,
uval
,
adj
);
mpz_clear
(
adj
);
}
size_t
ecount
;
mpz_export
(
phwi
,
&
ecount
,
-
1
,
sizeof
(
HOST_WIDE_INT
),
0
,
0
,
uval
);
go_assert
(
ecount
<=
count
);
// Trim down to the number of words required by the type.
size_t
obits
=
utype
->
integer_type
()
->
bits
();
if
(
!
utype
->
integer_type
()
->
is_unsigned
())
++
obits
;
size_t
ocount
=
((
obits
+
HOST_BITS_PER_WIDE_INT
-
1
)
/
HOST_BITS_PER_WIDE_INT
);
go_assert
(
ocount
<=
count
);
...
...
@@ -4322,6 +4331,16 @@ Unary_expression::eval_integer(Operator op, Type* utype, mpz_t uval, mpz_t val,
mpz_import
(
val
,
ocount
,
-
1
,
sizeof
(
HOST_WIDE_INT
),
0
,
0
,
phwi
);
if
(
!
utype
->
integer_type
()
->
is_unsigned
()
&&
mpz_tstbit
(
val
,
obits
-
1
))
{
mpz_t
adj
;
mpz_init_set_ui
(
adj
,
1
);
mpz_mul_2exp
(
adj
,
adj
,
obits
);
mpz_sub
(
val
,
val
,
adj
);
mpz_clear
(
adj
);
}
delete
[]
phwi
;
}
return
Integer_expression
::
check_constant
(
val
,
utype
,
location
);
...
...
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