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
047de90b
Commit
047de90b
authored
Apr 04, 1992
by
Richard Stallman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
*** empty log message ***
From-SVN: r682
parent
65d1fa2b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
43 deletions
+65
-43
gcc/c-common.c
+5
-0
gcc/c-typeck.c
+60
-43
No files found.
gcc/c-common.c
View file @
047de90b
...
...
@@ -389,8 +389,10 @@ binary_op_error (code)
case
RSHIFT_EXPR
:
opname
=
">>"
;
break
;
case
TRUNC_MOD_EXPR
:
case
FLOOR_MOD_EXPR
:
opname
=
"%"
;
break
;
case
TRUNC_DIV_EXPR
:
case
FLOOR_DIV_EXPR
:
opname
=
"/"
;
break
;
case
BIT_AND_EXPR
:
opname
=
"&"
;
break
;
...
...
@@ -402,6 +404,9 @@ binary_op_error (code)
opname
=
"||"
;
break
;
case
BIT_XOR_EXPR
:
opname
=
"^"
;
break
;
case
LROTATE_EXPR
:
case
RROTATE_EXPR
:
opname
=
"rotate"
;
break
;
}
error
(
"invalid operands to binary %s"
,
opname
);
}
...
...
gcc/c-typeck.c
View file @
047de90b
...
...
@@ -1714,6 +1714,10 @@ check_format (info, params)
/* Check the type of the "real" argument, if there's a type we want. */
if
(
i
==
fci
->
pointer_count
&&
wanted_type
!=
0
&&
wanted_type
!=
cur_type
/* If we want `void *', allow any pointer type.
(Anything else would already have got a warning.) */
&&
!
(
wanted_type
==
void_type_node
&&
fci
->
pointer_count
>
0
)
/* Don't warn about differences merely in signedness. */
&&
!
(
TREE_CODE
(
wanted_type
)
==
INTEGER_TYPE
&&
TREE_CODE
(
cur_type
)
==
INTEGER_TYPE
...
...
@@ -1724,9 +1728,12 @@ check_format (info, params)
this
=
IDENTIFIER_POINTER
(
DECL_NAME
(
TYPE_NAME
(
wanted_type
)));
that
=
0
;
if
(
TYPE_NAME
(
cur_type
)
!=
0
)
if
(
DECL_NAME
(
TYPE_NAME
(
cur_type
))
!=
0
)
that
=
IDENTIFIER_POINTER
(
DECL_NAME
(
TYPE_NAME
(
cur_type
)));
if
(
TYPE_NAME
(
cur_type
)
!=
0
&&
TREE_CODE
(
cur_type
)
!=
INTEGER_TYPE
&&
!
(
TREE_CODE
(
cur_type
)
==
POINTER_TYPE
&&
TREE_CODE
(
TREE_TYPE
(
cur_type
))
==
INTEGER_TYPE
)
&&
DECL_NAME
(
TYPE_NAME
(
cur_type
))
!=
0
)
that
=
IDENTIFIER_POINTER
(
DECL_NAME
(
TYPE_NAME
(
cur_type
)));
/* A nameless type can't possibly match what the format wants.
So there will be a warning for it.
...
...
@@ -1949,8 +1956,6 @@ convert_arguments (typelist, values, name)
if
(
warn_conversion
)
{
int
formal_prec
=
TYPE_PRECISION
(
type
);
int
actual_prec
=
TYPE_PRECISION
(
TREE_TYPE
(
val
));
int
int_prec
=
TYPE_PRECISION
(
integer_type_node
);
if
(
TREE_CODE
(
type
)
!=
REAL_TYPE
&&
TREE_CODE
(
TREE_TYPE
(
val
))
==
REAL_TYPE
)
...
...
@@ -1962,7 +1967,7 @@ convert_arguments (typelist, values, name)
&&
TREE_CODE
(
TREE_TYPE
(
val
))
==
REAL_TYPE
)
{
/* Warn if any argument is passed as `float',
since with
t
out a prototype it would be `double'. */
since without a prototype it would be `double'. */
if
(
formal_prec
==
TYPE_PRECISION
(
float_type_node
))
warning
(
"floating argument passed as `float' rather than `double'"
);
}
...
...
@@ -1975,7 +1980,7 @@ convert_arguments (typelist, values, name)
tree
would_have_been
=
default_conversion
(
val
);
tree
type1
=
TREE_TYPE
(
would_have_been
);
if
(
TYPE_PRECISION
(
type
)
!=
TYPE_PRECISION
(
type
))
if
(
formal_prec
!=
TYPE_PRECISION
(
type
))
warning
(
"prototype changes width used for integer argument"
);
else
if
(
TREE_UNSIGNED
(
type
)
==
TREE_UNSIGNED
(
type1
))
;
...
...
@@ -1984,6 +1989,12 @@ convert_arguments (typelist, values, name)
/* Change in signedness doesn't matter
if a constant value is unaffected. */
;
else
if
(
TREE_CODE
(
TREE_TYPE
(
val
))
==
ENUMERAL_TYPE
&&
int_fits_type_p
(
TYPE_MIN_VALUE
(
TREE_TYPE
(
val
)),
type
)
&&
int_fits_type_p
(
TYPE_MAX_VALUE
(
TREE_TYPE
(
val
)),
type
))
/* Change in signedness doesn't matter
if an enum value is unaffected. */
;
else
if
(
TREE_UNSIGNED
(
type
))
warning
(
"argument passed as unsigned due to prototype"
);
else
...
...
@@ -2288,6 +2299,7 @@ build_binary_op (code, orig_op0, orig_op1, convert_p)
break
;
case
TRUNC_MOD_EXPR
:
case
FLOOR_MOD_EXPR
:
if
(
code0
==
INTEGER_TYPE
&&
code1
==
INTEGER_TYPE
)
shorten
=
1
;
break
;
...
...
@@ -4334,13 +4346,15 @@ get_spelling (errtype)
/* Avoid counting chars */
static
char
message
[]
=
"initialization of `%s'"
;
register
int
needed
=
sizeof
(
message
)
+
spelling_length
()
+
1
;
char
*
temp
;
if
(
size
<
0
)
buffer
=
(
char
*
)
xmalloc
(
size
=
needed
);
if
(
needed
>
size
)
buffer
=
(
char
*
)
xrealloc
(
buffer
,
size
=
needed
);
sprintf
(
buffer
,
message
,
print_spelling
(
alloca
(
needed
)));
temp
=
(
char
*
)
alloca
(
needed
);
sprintf
(
buffer
,
message
,
print_spelling
(
temp
));
return
buffer
;
}
...
...
@@ -4429,6 +4443,7 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
tree node which has no TREE_TYPE. */
int
raw_constructor
=
TREE_CODE
(
init
)
==
CONSTRUCTOR
&&
TREE_TYPE
(
init
)
==
0
;
tree
inside_init
=
init
;
/* By default, assume we use one element from a list.
We correct this later in the sole case where it is not true. */
...
...
@@ -4444,13 +4459,13 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
if
(
TREE_CODE
(
init
)
==
NON_LVALUE_EXPR
)
init
=
TREE_OPERAND
(
init
,
0
);
in
side_in
it
=
TREE_OPERAND
(
init
,
0
);
if
(
init
&&
raw_constructor
&&
CONSTRUCTOR_ELTS
(
init
)
!=
0
&&
TREE_CHAIN
(
CONSTRUCTOR_ELTS
(
init
))
==
0
)
&&
CONSTRUCTOR_ELTS
(
in
side_in
it
)
!=
0
&&
TREE_CHAIN
(
CONSTRUCTOR_ELTS
(
in
side_in
it
))
==
0
)
{
element
=
TREE_VALUE
(
CONSTRUCTOR_ELTS
(
init
));
element
=
TREE_VALUE
(
CONSTRUCTOR_ELTS
(
in
side_in
it
));
/* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
if
(
element
&&
TREE_CODE
(
element
)
==
NON_LVALUE_EXPR
)
element
=
TREE_OPERAND
(
element
,
0
);
...
...
@@ -4467,10 +4482,10 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
||
typ1
==
unsigned_char_type_node
||
typ1
==
unsigned_wchar_type_node
||
typ1
==
signed_wchar_type_node
)
&&
((
in
it
&&
TREE_CODE
(
init
)
==
STRING_CST
)
&&
((
in
side_init
&&
TREE_CODE
(
inside_
init
)
==
STRING_CST
)
||
(
element
&&
TREE_CODE
(
element
)
==
STRING_CST
)))
{
tree
string
=
element
?
element
:
init
;
tree
string
=
element
?
element
:
in
side_in
it
;
if
((
TYPE_MAIN_VARIANT
(
TREE_TYPE
(
TREE_TYPE
(
string
)))
!=
char_type_node
)
...
...
@@ -4510,44 +4525,45 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
from an expression of the same type, optionally with braces.
For an array, this is allowed only for a string constant. */
if
(
in
it
&&
(
TREE_TYPE
(
init
)
==
type
||
(
code
==
ARRAY_TYPE
&&
TREE_TYPE
(
init
)
&&
comptypes
(
TREE_TYPE
(
init
),
type
))
if
(
in
side_init
&&
(
TREE_TYPE
(
inside_
init
)
==
type
||
(
code
==
ARRAY_TYPE
&&
TREE_TYPE
(
in
side_in
it
)
&&
comptypes
(
TREE_TYPE
(
in
side_in
it
),
type
))
||
(
code
==
POINTER_TYPE
&&
TREE_TYPE
(
init
)
!=
0
&&
(
TREE_CODE
(
TREE_TYPE
(
init
))
==
ARRAY_TYPE
||
TREE_CODE
(
TREE_TYPE
(
init
))
==
FUNCTION_TYPE
)
&&
comptypes
(
TREE_TYPE
(
TREE_TYPE
(
init
)),
&&
TREE_TYPE
(
in
side_in
it
)
!=
0
&&
(
TREE_CODE
(
TREE_TYPE
(
in
side_in
it
))
==
ARRAY_TYPE
||
TREE_CODE
(
TREE_TYPE
(
in
side_in
it
))
==
FUNCTION_TYPE
)
&&
comptypes
(
TREE_TYPE
(
TREE_TYPE
(
in
side_in
it
)),
TREE_TYPE
(
type
)))))
{
if
(
code
==
POINTER_TYPE
&&
(
TREE_CODE
(
TREE_TYPE
(
init
))
==
ARRAY_TYPE
||
TREE_CODE
(
TREE_TYPE
(
init
))
==
FUNCTION_TYPE
))
in
it
=
default_conversion
(
init
);
else
if
(
code
==
ARRAY_TYPE
&&
TREE_CODE
(
init
)
!=
STRING_CST
)
&&
(
TREE_CODE
(
TREE_TYPE
(
in
side_in
it
))
==
ARRAY_TYPE
||
TREE_CODE
(
TREE_TYPE
(
in
side_in
it
))
==
FUNCTION_TYPE
))
in
side_init
=
default_conversion
(
inside_
init
);
else
if
(
code
==
ARRAY_TYPE
&&
TREE_CODE
(
in
side_in
it
)
!=
STRING_CST
)
{
error_init
(
"array%s initialized from non-constant array expression"
,
" `%s'"
,
ofwhat
);
return
error_mark_node
;
}
if
(
optimize
&&
TREE_READONLY
(
init
)
&&
TREE_CODE
(
init
)
==
VAR_DECL
)
init
=
decl_constant_value
(
init
);
if
(
optimize
&&
TREE_READONLY
(
inside_init
)
&&
TREE_CODE
(
inside_init
)
==
VAR_DECL
)
inside_init
=
decl_constant_value
(
inside_init
);
if
(
require_constant
&&
!
TREE_CONSTANT
(
init
))
if
(
require_constant
&&
!
TREE_CONSTANT
(
in
side_in
it
))
{
error_init
(
"initializer element%s is not constant"
,
" for `%s'"
,
ofwhat
);
init
=
error_mark_node
;
in
side_in
it
=
error_mark_node
;
}
else
if
(
require_constant
&&
initializer_constant_valid_p
(
init
)
==
0
)
else
if
(
require_constant
&&
initializer_constant_valid_p
(
in
side_in
it
)
==
0
)
{
error_init
(
"initializer element%s is not computable at load time"
,
" for `%s'"
,
ofwhat
);
init
=
error_mark_node
;
in
side_in
it
=
error_mark_node
;
}
return
init
;
return
in
side_in
it
;
}
if
(
element
&&
(
TREE_TYPE
(
element
)
==
type
...
...
@@ -4608,7 +4624,7 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
push_member_name
(
IDENTIFIER_POINTER
(
DECL_NAME
(
field
)));
if
(
raw_constructor
)
result
=
process_init_constructor
(
type
,
init
,
0
,
result
=
process_init_constructor
(
type
,
in
side_in
it
,
0
,
require_constant
,
constructor_constant
,
0
);
else
if
(
tail
!=
0
)
...
...
@@ -4640,11 +4656,11 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
" `%s'"
,
ofwhat
);
return
error_mark_node
;
}
init
=
element
;
in
side_in
it
=
element
;
}
#if 0 /* A non-raw constructor is an actual expression. */
if (TREE_CODE (init) == CONSTRUCTOR)
if (TREE_CODE (in
side_in
it) == CONSTRUCTOR)
{
error_init ("initializer for scalar%s has extra braces",
" `%s'", ofwhat);
...
...
@@ -4656,24 +4672,24 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
({
if
(
ofwhat
)
push_string
(
ofwhat
);
init
=
convert_for_assignment
(
type
,
default_conversion
(
init
),
in
side_in
it
=
convert_for_assignment
(
type
,
default_conversion
(
init
),
&
initialization_message
,
NULL_TREE
,
0
);
});
if
(
require_constant
&&
!
TREE_CONSTANT
(
init
))
if
(
require_constant
&&
!
TREE_CONSTANT
(
in
side_in
it
))
{
error_init
(
"initializer element%s is not constant"
,
" for `%s'"
,
ofwhat
);
init
=
error_mark_node
;
in
side_in
it
=
error_mark_node
;
}
else
if
(
require_constant
&&
initializer_constant_valid_p
(
init
)
==
0
)
else
if
(
require_constant
&&
initializer_constant_valid_p
(
in
side_in
it
)
==
0
)
{
error_init
(
"initializer element%s is not computable at load time"
,
" for `%s'"
,
ofwhat
);
init
=
error_mark_node
;
in
side_in
it
=
error_mark_node
;
}
return
init
;
return
in
side_in
it
;
}
/* Come here only for records and arrays. */
...
...
@@ -4688,7 +4704,8 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
if
(
code
==
ARRAY_TYPE
||
code
==
RECORD_TYPE
)
{
if
(
raw_constructor
)
return
process_init_constructor
(
type
,
init
,
0
,
constructor_constant
,
return
process_init_constructor
(
type
,
inside_init
,
0
,
constructor_constant
,
constructor_constant
,
ofwhat
);
else
if
(
tail
!=
0
)
{
...
...
@@ -4700,7 +4717,7 @@ digest_init (type, init, tail, require_constant, constructor_constant, ofwhat)
/* Traditionally one can say `char x[100] = 0;'. */
return
process_init_constructor
(
type
,
build_nt
(
CONSTRUCTOR
,
0
,
tree_cons
(
0
,
init
,
0
)),
tree_cons
(
0
,
in
side_in
it
,
0
)),
0
,
constructor_constant
,
constructor_constant
,
ofwhat
);
}
...
...
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