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
3f85558f
Commit
3f85558f
authored
23 years ago
by
Richard Henderson
Committed by
Richard Henderson
23 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* c-typeck.c (comptypes): Handle zero-length arrays properly.
From-SVN: r45641
parent
c6c04fca
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
6 deletions
+65
-6
gcc/ChangeLog
+4
-0
gcc/c-typeck.c
+19
-6
gcc/testsuite/gcc.dg/array-5.c
+42
-0
No files found.
gcc/ChangeLog
View file @
3f85558f
2001
-
09
-
15
Richard
Henderson
<
rth
@redhat
.
com
>
*
c
-
typeck
.
c
(
comptypes
)
:
Handle
zero
-
length
arrays
properly
.
2001
-
09
-
15
Roman
Lechtchinsky
<
rl
@cs
.
tu
-
berlin
.
de
>
*
c
-
common
.
c
(
c_promoting_integer_type_p
)
:
Handle
?
Imode
types
.
...
...
This diff is collapsed.
Click to expand it.
gcc/c-typeck.c
View file @
3f85558f
...
...
@@ -505,6 +505,8 @@ comptypes (type1, type2)
{
tree
d1
=
TYPE_DOMAIN
(
t1
);
tree
d2
=
TYPE_DOMAIN
(
t2
);
bool
d1_variable
,
d2_variable
;
bool
d1_zero
,
d2_zero
;
val
=
1
;
/* Target types must match incl. qualifiers. */
...
...
@@ -513,14 +515,25 @@ comptypes (type1, type2)
return
0
;
/* Sizes must match unless one is missing or variable. */
if
(
d1
==
0
||
d2
==
0
||
d1
==
d2
||
TREE_CODE
(
TYPE_MIN_VALUE
(
d1
))
!=
INTEGER_CST
||
TREE_CODE
(
TYPE_MIN_VALUE
(
d2
))
!=
INTEGER_CST
||
TREE_CODE
(
TYPE_MAX_VALUE
(
d1
))
!=
INTEGER_CST
||
TREE_CODE
(
TYPE_MAX_VALUE
(
d2
))
!=
INTEGER_CST
)
if
(
d1
==
0
||
d2
==
0
||
d1
==
d2
)
break
;
if
(
!
tree_int_cst_equal
(
TYPE_MIN_VALUE
(
d1
),
TYPE_MIN_VALUE
(
d2
))
d1_zero
=
!
TYPE_MAX_VALUE
(
d1
);
d2_zero
=
!
TYPE_MAX_VALUE
(
d2
);
d1_variable
=
(
!
d1_zero
&&
(
TREE_CODE
(
TYPE_MIN_VALUE
(
d1
))
!=
INTEGER_CST
||
TREE_CODE
(
TYPE_MAX_VALUE
(
d1
))
!=
INTEGER_CST
));
d2_variable
=
(
!
d2_zero
&&
(
TREE_CODE
(
TYPE_MIN_VALUE
(
d2
))
!=
INTEGER_CST
||
TREE_CODE
(
TYPE_MAX_VALUE
(
d2
))
!=
INTEGER_CST
));
if
(
d1_variable
||
d2_variable
)
break
;
if
(
d1_zero
&&
d2_zero
)
break
;
if
(
d1_zero
||
d2_zero
||
!
tree_int_cst_equal
(
TYPE_MIN_VALUE
(
d1
),
TYPE_MIN_VALUE
(
d2
))
||
!
tree_int_cst_equal
(
TYPE_MAX_VALUE
(
d1
),
TYPE_MAX_VALUE
(
d2
)))
val
=
0
;
...
...
This diff is collapsed.
Click to expand it.
gcc/testsuite/gcc.dg/array-5.c
0 → 100644
View file @
3f85558f
/* { dg-do compile } */
/* { dg-options "" } */
/* Check compatibility of array declarations. */
/* Incomplete decl matches. */
extern
char
arr0
[];
char
arr0
[
1
];
/* Two integral expressions must be the same. Note that 0 is
a gcc extension, but it should work like any other constant. */
extern
char
arr1
[
1
];
char
arr1
[
1
];
extern
char
arr2
[
0
];
char
arr2
[
0
];
extern
char
arr3
[
0
];
/* { dg-error "previous declaration" } */
char
arr3
[
1
];
/* { dg-error "conflicting types" } */
/* Variable size matches. */
void
func
(
int
n
,
int
m
)
{
/* The next two are from the example in c99 6.7.5.2/9. */
{
/* Invalid: not compatible because 4 != 6. */
int
a
[
n
][
6
][
m
];
int
(
*
p
)[
4
][
n
+
1
];
p
=
a
;
/* { dg-error "incompatible" } */
}
{
/* Compatible, but defined behavior only if n == 6 and m == n+1. */
int
c
[
n
][
n
][
6
][
m
];
int
(
*
r
)[
n
][
n
][
n
+
1
];
r
=
c
;
}
{
/* Compatible, but undefined behavior; (2, 2) is not a constant
expression, and thus A is a VLA. */
int
a
[(
2
,
2
)];
int
(
*
p
)[
3
];
p
=
a
;
/* { dg-bogus "incompatible" "bad vla handling" { xfail *-*-* } } */
}
}
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