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
a360da3a
Commit
a360da3a
authored
Jan 17, 1995
by
Jason Merrill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use boolean_* instead of integer_* where appropriate.
From-SVN: r8768
parent
4812480a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
30 deletions
+31
-30
gcc/c-common.c
+31
-30
No files found.
gcc/c-common.c
View file @
a360da3a
...
...
@@ -1660,40 +1660,40 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr)
if
(
code
==
NE_EXPR
)
{
if
(
max_lt
||
min_gt
)
val
=
integer_on
e_node
;
val
=
boolean_tru
e_node
;
}
else
if
(
code
==
EQ_EXPR
)
{
if
(
max_lt
||
min_gt
)
val
=
integer_zero
_node
;
val
=
boolean_false
_node
;
}
else
if
(
code
==
LT_EXPR
)
{
if
(
max_lt
)
val
=
integer_on
e_node
;
val
=
boolean_tru
e_node
;
if
(
!
min_lt
)
val
=
integer_zero
_node
;
val
=
boolean_false
_node
;
}
else
if
(
code
==
GT_EXPR
)
{
if
(
min_gt
)
val
=
integer_on
e_node
;
val
=
boolean_tru
e_node
;
if
(
!
max_gt
)
val
=
integer_zero
_node
;
val
=
boolean_false
_node
;
}
else
if
(
code
==
LE_EXPR
)
{
if
(
!
max_gt
)
val
=
integer_on
e_node
;
val
=
boolean_tru
e_node
;
if
(
min_gt
)
val
=
integer_zero
_node
;
val
=
boolean_false
_node
;
}
else
if
(
code
==
GE_EXPR
)
{
if
(
!
min_lt
)
val
=
integer_on
e_node
;
val
=
boolean_tru
e_node
;
if
(
max_lt
)
val
=
integer_zero
_node
;
val
=
boolean_false
_node
;
}
/* If primop0 was sign-extended and unsigned comparison specd,
...
...
@@ -1731,18 +1731,18 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr)
{
/* This is the case of (char)x >?< 0x80, which people used to use
expecting old C compilers to change the 0x80 into -0x80. */
if
(
val
==
integer_zero
_node
)
if
(
val
==
boolean_false
_node
)
warning
(
"comparison is always 0 due to limited range of data type"
);
if
(
val
==
integer_on
e_node
)
if
(
val
==
boolean_tru
e_node
)
warning
(
"comparison is always 1 due to limited range of data type"
);
}
if
(
!
min_lt
&&
unsignedp0
&&
TREE_CODE
(
primop0
)
!=
INTEGER_CST
)
{
/* This is the case of (unsigned char)x >?< -1 or < 0. */
if
(
val
==
integer_zero
_node
)
if
(
val
==
boolean_false
_node
)
warning
(
"comparison is always 0 due to limited range of data type"
);
if
(
val
==
integer_on
e_node
)
if
(
val
==
boolean_tru
e_node
)
warning
(
"comparison is always 1 due to limited range of data type"
);
}
...
...
@@ -1810,7 +1810,7 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr)
&&
!
TREE_OVERFLOW
(
convert
(
signed_type
(
type
),
primop0
))))
warning
(
"unsigned value >= 0 is always 1"
);
value
=
integer_on
e_node
;
value
=
boolean_tru
e_node
;
break
;
case
LT_EXPR
:
...
...
@@ -1819,7 +1819,7 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr)
&&
!
TREE_OVERFLOW
(
convert
(
signed_type
(
type
),
primop0
))))
warning
(
"unsigned value < 0 is always 0"
);
value
=
integer_zero
_node
;
value
=
boolean_false
_node
;
}
if
(
value
!=
0
)
...
...
@@ -1836,7 +1836,7 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr)
*
op0_ptr
=
convert
(
type
,
primop0
);
*
op1_ptr
=
convert
(
type
,
primop1
);
*
restype_ptr
=
integer
_type_node
;
*
restype_ptr
=
boolean
_type_node
;
return
0
;
}
...
...
@@ -1847,10 +1847,10 @@ shorten_compare (op0_ptr, op1_ptr, restype_ptr, rescode_ptr)
This preparation consists of taking the ordinary
representation of an expression expr and producing a valid tree
boolean expression describing whether expr is nonzero. We could
simply always do build_binary_op (NE_EXPR, expr,
integer_zero
_node, 1),
simply always do build_binary_op (NE_EXPR, expr,
boolean_false
_node, 1),
but we optimize comparisons, &&, ||, and !.
The resulting type should always be `
integer
_type_node'. */
The resulting type should always be `
boolean
_type_node'. */
tree
truthvalue_conversion
(
expr
)
...
...
@@ -1866,15 +1866,15 @@ truthvalue_conversion (expr)
{
case RECORD_TYPE:
error ("struct type value used where scalar is required");
return
integer_zero
_node;
return
boolean_false
_node;
case UNION_TYPE:
error ("union type value used where scalar is required");
return
integer_zero
_node;
return
boolean_false
_node;
case ARRAY_TYPE:
error ("array type value used where scalar is required");
return
integer_zero
_node;
return
boolean_false
_node;
default:
break;
...
...
@@ -1907,23 +1907,24 @@ truthvalue_conversion (expr)
case
TRUTH_AND_EXPR
:
case
TRUTH_OR_EXPR
:
case
TRUTH_XOR_EXPR
:
return
convert
(
integer_type_node
,
expr
);
TREE_TYPE
(
expr
)
=
boolean_type_node
;
return
expr
;
case
ERROR_MARK
:
return
expr
;
case
INTEGER_CST
:
return
integer_zerop
(
expr
)
?
integer_zero_node
:
integer_on
e_node
;
return
integer_zerop
(
expr
)
?
boolean_false_node
:
boolean_tru
e_node
;
case
REAL_CST
:
return
real_zerop
(
expr
)
?
integer_zero_node
:
integer_on
e_node
;
return
real_zerop
(
expr
)
?
boolean_false_node
:
boolean_tru
e_node
;
case
ADDR_EXPR
:
if
(
TREE_SIDE_EFFECTS
(
TREE_OPERAND
(
expr
,
0
)))
return
build
(
COMPOUND_EXPR
,
integer
_type_node
,
TREE_OPERAND
(
expr
,
0
),
integer_on
e_node
);
return
build
(
COMPOUND_EXPR
,
boolean
_type_node
,
TREE_OPERAND
(
expr
,
0
),
boolean_tru
e_node
);
else
return
integer_on
e_node
;
return
boolean_tru
e_node
;
case
COMPLEX_EXPR
:
return
build_binary_op
((
TREE_SIDE_EFFECTS
(
TREE_OPERAND
(
expr
,
1
))
...
...
@@ -1944,14 +1945,14 @@ truthvalue_conversion (expr)
/* These don't change whether an object is zero or non-zero, but
we can't ignore them if their second arg has side-effects. */
if
(
TREE_SIDE_EFFECTS
(
TREE_OPERAND
(
expr
,
1
)))
return
build
(
COMPOUND_EXPR
,
integer
_type_node
,
TREE_OPERAND
(
expr
,
1
),
return
build
(
COMPOUND_EXPR
,
boolean
_type_node
,
TREE_OPERAND
(
expr
,
1
),
truthvalue_conversion
(
TREE_OPERAND
(
expr
,
0
)));
else
return
truthvalue_conversion
(
TREE_OPERAND
(
expr
,
0
));
case
COND_EXPR
:
/* Distribute the conversion into the arms of a COND_EXPR. */
return
fold
(
build
(
COND_EXPR
,
integer
_type_node
,
TREE_OPERAND
(
expr
,
0
),
return
fold
(
build
(
COND_EXPR
,
boolean
_type_node
,
TREE_OPERAND
(
expr
,
0
),
truthvalue_conversion
(
TREE_OPERAND
(
expr
,
1
)),
truthvalue_conversion
(
TREE_OPERAND
(
expr
,
2
))));
...
...
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