Skip to content

Commit 2416b14

Browse files
committed
C model library: avoid duplicate *scanf definitions
glibc headers define C99 variants via asm renaming. Library checks (rightly) failed when using clang 14, reporting duplicate definitions. Fixes: #7366
1 parent 18b7c76 commit 2416b14

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/ansi-c/library/stdio.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,8 @@ void perror(const char *s)
824824

825825
/* FUNCTION: fscanf */
826826

827+
#if !defined(__USE_ISOC99) || !defined(__REDIRECT)
828+
827829
#ifndef __CPROVER_STDIO_H_INCLUDED
828830
#include <stdio.h>
829831
#define __CPROVER_STDIO_H_INCLUDED
@@ -844,6 +846,8 @@ __CPROVER_HIDE:;
844846
return result;
845847
}
846848

849+
#endif
850+
847851
/* FUNCTION: __isoc99_fscanf */
848852

849853
#ifndef __CPROVER_STDIO_H_INCLUDED
@@ -868,6 +872,8 @@ __CPROVER_HIDE:;
868872

869873
/* FUNCTION: scanf */
870874

875+
#if !defined(__USE_ISOC99) || !defined(__REDIRECT)
876+
871877
#ifndef __CPROVER_STDIO_H_INCLUDED
872878
#include <stdio.h>
873879
#define __CPROVER_STDIO_H_INCLUDED
@@ -888,6 +894,8 @@ __CPROVER_HIDE:;
888894
return result;
889895
}
890896

897+
#endif
898+
891899
/* FUNCTION: __isoc99_scanf */
892900

893901
#ifndef __CPROVER_STDIO_H_INCLUDED
@@ -912,6 +920,8 @@ __CPROVER_HIDE:;
912920

913921
/* FUNCTION: sscanf */
914922

923+
#if !defined(__USE_ISOC99) || !defined(__REDIRECT)
924+
915925
#ifndef __CPROVER_STDIO_H_INCLUDED
916926
#include <stdio.h>
917927
#define __CPROVER_STDIO_H_INCLUDED
@@ -932,6 +942,8 @@ __CPROVER_HIDE:;
932942
return result;
933943
}
934944

945+
#endif
946+
935947
/* FUNCTION: __isoc99_sscanf */
936948

937949
#ifndef __CPROVER_STDIO_H_INCLUDED
@@ -956,6 +968,8 @@ __CPROVER_HIDE:;
956968

957969
/* FUNCTION: vfscanf */
958970

971+
#if !defined(__USE_ISOC99) || !defined(__REDIRECT)
972+
959973
#ifndef __CPROVER_STDIO_H_INCLUDED
960974
#include <stdio.h>
961975
#define __CPROVER_STDIO_H_INCLUDED
@@ -998,6 +1012,8 @@ int vfscanf(FILE *restrict stream, const char *restrict format, va_list arg)
9981012
return result;
9991013
}
10001014

1015+
#endif
1016+
10011017
/* FUNCTION: __isoc99_vfscanf */
10021018

10031019
#ifndef __CPROVER_STDIO_H_INCLUDED
@@ -1098,6 +1114,8 @@ int __stdio_common_vfscanf(
10981114

10991115
/* FUNCTION: vscanf */
11001116

1117+
#if !defined(__USE_ISOC99) || !defined(__REDIRECT)
1118+
11011119
#ifndef __CPROVER_STDIO_H_INCLUDED
11021120
#include <stdio.h>
11031121
#define __CPROVER_STDIO_H_INCLUDED
@@ -1114,6 +1132,8 @@ int vscanf(const char *restrict format, va_list arg)
11141132
return vfscanf(stdin, format, arg);
11151133
}
11161134

1135+
#endif
1136+
11171137
/* FUNCTION: __isoc99_vscanf */
11181138

11191139
#ifndef __CPROVER_STDIO_H_INCLUDED
@@ -1134,6 +1154,8 @@ __CPROVER_HIDE:;
11341154

11351155
/* FUNCTION: vsscanf */
11361156

1157+
#if !defined(__USE_ISOC99) || !defined(__REDIRECT)
1158+
11371159
#ifndef __CPROVER_STDIO_H_INCLUDED
11381160
#include <stdio.h>
11391161
#define __CPROVER_STDIO_H_INCLUDED
@@ -1162,6 +1184,8 @@ __CPROVER_HIDE:;
11621184
return result;
11631185
}
11641186

1187+
#endif
1188+
11651189
/* FUNCTION: __isoc99_vsscanf */
11661190

11671191
#ifndef __CPROVER_STDIO_H_INCLUDED

0 commit comments

Comments
 (0)