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
4c42625b
Commit
4c42625b
authored
32 years ago
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(convert_to_integer): Warn if integer is truncated and that changes the value.
From-SVN: r3496
parent
3c15ff86
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
gcc/convert.c
+24
-0
No files found.
gcc/convert.c
View file @
4c42625b
...
...
@@ -172,6 +172,30 @@ convert_to_integer (type, expr)
switch
(
ex_form
)
{
case
INTEGER_CST
:
if
(
TREE_UNSIGNED
(
type
))
{
if
(
TREE_INT_CST_LOW
(
expr
)
>>
outprec
)
warning
(
"integer constant truncated"
);
}
else
{
/* if the sign bit of the low-order part isn't replicated
through the entire high part, we have overflow */
int
sign
=
TREE_INT_CST_LOW
(
expr
)
&
(
1
<<
(
outprec
-
1
));
if
(
!
sign
)
/* lower part positive */
{
if
(
TREE_INT_CST_LOW
(
expr
)
>>
outprec
)
warning
(
"integer constant truncated"
);
}
else
{
if
((
TREE_INT_CST_LOW
(
expr
)
>>
outprec
)
+
1
)
warning
(
"integer constant truncated"
);
}
}
break
;
case
RSHIFT_EXPR
:
/* We can pass truncation down through right shifting
when the shift count is a nonpositive constant. */
...
...
This diff is collapsed.
Click to expand it.
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