Skip to content

Commit f6fd739

Browse files
committed
C front-end: tolerate type differences with asm renaming
The example found in glibc shows how asm renaming may be combined with changes in return type names (even when there isn't actually a bit-level difference amongst the types). Weakening the asm-renamed declaration by marking it "incomplete" works around this problem.
1 parent 8eeb5fa commit f6fd739

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

regression/ansi-c/asm4/main.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// from Fedora's glibc
2+
struct dirent
3+
{
4+
int dummy;
5+
};
6+
7+
struct dirent64
8+
{
9+
int dummy;
10+
};
11+
12+
#ifdef __GNUC__
13+
extern struct dirent *readdir(void *__dirp) __asm__(
14+
""
15+
"readdir64");
16+
extern struct dirent64 *readdir64(void *__dirp);
17+
#endif
18+
19+
int main()
20+
{
21+
#ifdef __GNUC__
22+
int x;
23+
(void)readdir(&x);
24+
#endif
25+
return 0;
26+
}

regression/ansi-c/asm4/test.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE test-c++-front-end
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
--
7+
^warning: ignoring
8+
^CONVERSION ERROR$

src/ansi-c/c_typecheck_base.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,10 @@ void c_typecheck_baset::apply_asm_label(
668668
{
669669
symbol.name=asm_label;
670670
symbol.base_name=asm_label;
671+
// asm renaming may be combined with varied return types - make sure the
672+
// actual definition sets the final type
673+
if(symbol.type.id() == ID_code)
674+
symbol.type.set(ID_C_incomplete, true);
671675
}
672676

673677
if(symbol.name!=orig_name)

0 commit comments

Comments
 (0)