]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/9367 (error: nonnull argument with extern "C" snprintf prototype)
authorRoger Sayle <roger@eyesopen.com>
Sun, 2 Mar 2003 01:34:34 +0000 (01:34 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sun, 2 Mar 2003 01:34:34 +0000 (01:34 +0000)
PR c++/9367
* builtin-types.def (DEF_FUNCTION_TYPE_VAR_3): New macro.
(BT_FN_INT_CONST_STRING_VALIST_ARG,
BT_FN_INT_STRING_CONST_STRING_VALIST_ARG,
BT_FN_INT_CONST_STRING_CONST_STRING_VALIST_ARG,
BT_FN_INT_STRING_SIZE_CONST_STRING_VALIST_ARG,
BT_FN_INT_STRING_CONST_STRING_VAR,
BT_FN_INT_CONST_STRING_CONST_STRING_VAR,
BT_FN_INT_STRING_SIZE_CONST_STRING_VAR): New built-in types.
* builtin-attrs.def (ATTR_NONNULL_1, ATTR_NONNULL_2,
ATTR_NONNULL_3): Also include the nothrow attribute.
(sprintf, scanf, sscanf, vprintf, vsprintf, snprintf,
vsnprintf, vscanf, vsscanf): Don't define attributes here.
* builtins.def (putchar, puts): Make full C89 built-ins.
(snprintf, sprintf, scanf, sscanf, vprintf, vscanf,
vsscanf, vsnprintf, vsprintf): New built-ins.
* c-common.c (c_common_nodes_and_builtins): Handle new macro
DEF_FUNCTION_TYPE_VAR_3.

* doc/extend.texi: Document these new built-in functions.

* java/builtins.c (builtin_type): Handle DEF_FUNCTION_TYPE_VAR_3.
(initialize_builtins): Handle DEF_FUNCTION_TYPE_VAR_3.

* g++.old-deja/g++.other/builtins10.C: New test for PR 9367.
* gcc.dg/format/attr-5.c: Handle new conflicting types warning.

From-SVN: r63650

gcc/ChangeLog
gcc/builtin-attrs.def
gcc/builtin-types.def
gcc/builtins.def
gcc/c-common.c
gcc/doc/extend.texi
gcc/java/ChangeLog
gcc/java/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.old-deja/g++.other/builtins10.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/format/attr-5.c

index fdd350db14226c61696c5a5c0bf54113fe2dd703..61dca7ead8fbbd710db6c605474a18c204abc115 100644 (file)
@@ -1,3 +1,26 @@
+2003-03-01  Roger Sayle  <roger@eyesopen.com>
+
+       PR c++/9367
+       * builtin-types.def (DEF_FUNCTION_TYPE_VAR_3): New macro.
+       (BT_FN_INT_CONST_STRING_VALIST_ARG,
+       BT_FN_INT_STRING_CONST_STRING_VALIST_ARG,
+       BT_FN_INT_CONST_STRING_CONST_STRING_VALIST_ARG,
+       BT_FN_INT_STRING_SIZE_CONST_STRING_VALIST_ARG,
+       BT_FN_INT_STRING_CONST_STRING_VAR,
+       BT_FN_INT_CONST_STRING_CONST_STRING_VAR,
+       BT_FN_INT_STRING_SIZE_CONST_STRING_VAR): New built-in types.
+       * builtin-attrs.def (ATTR_NONNULL_1, ATTR_NONNULL_2,
+       ATTR_NONNULL_3): Also include the nothrow attribute.
+       (sprintf, scanf, sscanf, vprintf, vsprintf, snprintf,
+       vsnprintf, vscanf, vsscanf): Don't define attributes here.
+       * builtins.def (putchar, puts): Make full C89 built-ins.
+       (snprintf, sprintf, scanf, sscanf, vprintf, vscanf,
+       vsscanf, vsnprintf, vsprintf): New built-ins.
+       * c-common.c (c_common_nodes_and_builtins): Handle new macro
+       DEF_FUNCTION_TYPE_VAR_3.
+
+       * doc/extend.texi: Document these new built-in functions.
+
 2003-03-01  Kazu Hirata  <kazu@cs.umass.edu>
 
        * config/h8300/h8300.md (a peephole2): New.
index b307151d5089279f3214f5cded8b102d12b72a76..7bdbd6280865f39b73d63becb7f7e3ea25e7c461 100644 (file)
@@ -102,9 +102,12 @@ DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN,     \
 DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC,     \
                        ATTR_NULL, ATTR_NOTHROW_LIST)
 
-DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, ATTR_NULL)
-DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL)
-DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, ATTR_NULL)
+DEF_ATTR_TREE_LIST (ATTR_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
+                       ATTR_NOTHROW_LIST)
+DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \
+                       ATTR_NOTHROW_LIST)
+DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \
+                       ATTR_NOTHROW_LIST)
 
 /* Construct a tree for a format attribute.  */
 #define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES)                          \
@@ -149,13 +152,8 @@ DEF_FORMAT_ARG_ATTRIBUTE(2)
 
 /* Functions from ISO/IEC 9899:1990.  */
 #define DEF_C89_ATTR(NAME, ATTRS) DEF_FN_ATTR_IDENT (NAME, ATTRS, flag_hosted)
-DEF_C89_ATTR (sprintf, ATTR_FORMAT_PRINTF_2_3)
-DEF_C89_ATTR (scanf, ATTR_FORMAT_SCANF_1_2)
 DEF_C89_ATTR (fscanf, ATTR_FORMAT_SCANF_2_3)
-DEF_C89_ATTR (sscanf, ATTR_FORMAT_SCANF_2_3)
-DEF_C89_ATTR (vprintf, ATTR_FORMAT_PRINTF_1_0)
 DEF_C89_ATTR (vfprintf, ATTR_FORMAT_PRINTF_2_0)
-DEF_C89_ATTR (vsprintf, ATTR_FORMAT_PRINTF_2_0)
 DEF_C89_ATTR (strftime, ATTR_FORMAT_STRFTIME_3_0)
 #undef DEF_C89_ATTR
 
@@ -164,11 +162,7 @@ DEF_C89_ATTR (strftime, ATTR_FORMAT_STRFTIME_3_0)
   DEF_FN_ATTR_IDENT (NAME, ATTRS,                                          \
               (flag_hosted                                                 \
                && (flag_isoc99 || flag_noniso_default_format_attributes)))
-DEF_C99_ATTR (snprintf, ATTR_FORMAT_PRINTF_3_4)
-DEF_C99_ATTR (vsnprintf, ATTR_FORMAT_PRINTF_3_0)
-DEF_C99_ATTR (vscanf, ATTR_FORMAT_SCANF_1_0)
 DEF_C99_ATTR (vfscanf, ATTR_FORMAT_SCANF_2_0)
-DEF_C99_ATTR (vsscanf, ATTR_FORMAT_SCANF_2_0)
 #undef DEF_C99_ATTR
 
 /* Functions not in any version of ISO C.  */
index 9fa0f4e6f2c766b861b0e742432c78db979399ea..c095d07b609f8a14355378ad93addaf6ca987aa6 100644 (file)
@@ -40,6 +40,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
    DEF_FUNCTION_TYPE_VAR_0 (ENUM, RETURN)
    DEF_FUNCTION_TYPE_VAR_1 (ENUM, RETURN, ARG1)
    DEF_FUNCTION_TYPE_VAR_2 (ENUM, RETURN, ARG1, ARG2)
+   DEF_FUNCTION_TYPE_VAR_3 (ENUM, RETURN, ARG1, ARG2, ARG3)
 
      Similar, but for function types that take variable arguments.
      For example:
@@ -155,6 +156,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_DOUBLE,
                     BT_DOUBLE, BT_DOUBLE, BT_DOUBLE)
 DEF_FUNCTION_TYPE_2 (BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
                     BT_LONG_DOUBLE, BT_LONG_DOUBLE, BT_LONG_DOUBLE)
+DEF_FUNCTION_TYPE_2 (BT_FN_INT_CONST_STRING_VALIST_ARG,
+                    BT_INT, BT_CONST_STRING, BT_VALIST_ARG)
 
 DEF_FUNCTION_TYPE_3 (BT_FN_STRING_STRING_CONST_STRING_SIZE,
                     BT_STRING, BT_STRING, BT_CONST_STRING, BT_SIZE)
@@ -166,10 +169,17 @@ DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_PTR_CONST_PTR_SIZE,
                     BT_INT, BT_CONST_PTR, BT_CONST_PTR, BT_SIZE)
 DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_INT_SIZE,
                     BT_PTR, BT_PTR, BT_INT, BT_SIZE)
-DEF_FUNCTION_TYPE_3 (BT_FN_VOID_PTR_INT_INT, BT_VOID, BT_PTR, BT_INT, BT_INT)
+DEF_FUNCTION_TYPE_3 (BT_FN_VOID_PTR_INT_INT,
+                    BT_VOID, BT_PTR, BT_INT, BT_INT)
+DEF_FUNCTION_TYPE_3 (BT_FN_INT_STRING_CONST_STRING_VALIST_ARG,
+                    BT_INT, BT_STRING, BT_CONST_STRING, BT_VALIST_ARG)
+DEF_FUNCTION_TYPE_3 (BT_FN_INT_CONST_STRING_CONST_STRING_VALIST_ARG,
+                    BT_INT, BT_CONST_STRING, BT_CONST_STRING, BT_VALIST_ARG)
 
 DEF_FUNCTION_TYPE_4 (BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR,
                     BT_SIZE, BT_CONST_PTR, BT_SIZE, BT_SIZE, BT_PTR)
+DEF_FUNCTION_TYPE_4 (BT_FN_INT_STRING_SIZE_CONST_STRING_VALIST_ARG,
+               BT_INT, BT_STRING, BT_SIZE, BT_CONST_STRING, BT_VALIST_ARG)
 
 DEF_FUNCTION_TYPE_VAR_0 (BT_FN_VOID_VAR, BT_VOID)
 DEF_FUNCTION_TYPE_VAR_0 (BT_FN_INT_VAR, BT_INT)
@@ -184,6 +194,13 @@ DEF_FUNCTION_TYPE_VAR_1 (BT_FN_INT_CONST_STRING_VAR,
 
 DEF_FUNCTION_TYPE_VAR_2 (BT_FN_INT_PTR_CONST_STRING_VAR,
                         BT_INT, BT_PTR, BT_CONST_STRING)
+DEF_FUNCTION_TYPE_VAR_2 (BT_FN_INT_STRING_CONST_STRING_VAR,
+                        BT_INT, BT_STRING, BT_CONST_STRING)
+DEF_FUNCTION_TYPE_VAR_2 (BT_FN_INT_CONST_STRING_CONST_STRING_VAR,
+                        BT_INT, BT_CONST_STRING, BT_CONST_STRING)
+
+DEF_FUNCTION_TYPE_VAR_3 (BT_FN_INT_STRING_SIZE_CONST_STRING_VAR,
+                        BT_INT, BT_STRING, BT_SIZE, BT_CONST_STRING)
 
 DEF_POINTER_TYPE (BT_PTR_FN_VOID_VAR, BT_FN_VOID_VAR)
 DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE,
index ae7d640f581aed8199c57007a6c41388726adf42..48fd19762ae1ab4ef9ea19d30f8cb52cc05a105d 100644 (file)
@@ -711,27 +711,69 @@ DEF_GCC_BUILTIN(BUILT_IN_PREFETCH,
                BT_FN_VOID_CONST_PTR_VAR,
                ATTR_NULL)
 
-/* Stdio builtins.  */
-DEF_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR,
-                   "__builtin_putchar",
-                    BT_FN_INT_INT,
-                    ATTR_NOTHROW_LIST)
-DEF_FALLBACK_BUILTIN(BUILT_IN_PUTS,
-                    "__builtin_puts",
-                    BT_FN_INT_CONST_STRING,
-                    ATTR_NOTHROW_LIST)
+/* stdio.h builtins (without FILE *).  */
+
 DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF,
                          "__builtin_printf",
                          BT_FN_INT_CONST_STRING_VAR,
                          ATTR_FORMAT_PRINTF_1_2)
-DEF_FALLBACK_BUILTIN(BUILT_IN_FPUTC,
-                    "__builtin_fputc",
-                    BT_FN_INT_INT_PTR,
-                    ATTR_NOTHROW_LIST)
+DEF_LIB_BUILTIN(BUILT_IN_PUTCHAR,
+               "__builtin_putchar",
+               BT_FN_INT_INT,
+               ATTR_NOTHROW_LIST)
+DEF_LIB_BUILTIN(BUILT_IN_PUTS,
+               "__builtin_puts",
+               BT_FN_INT_CONST_STRING,
+               ATTR_NOTHROW_LIST)
+DEF_C99_BUILTIN(BUILT_IN_SNPRINTF,
+               "__builtin_snprintf",
+               BT_FN_INT_STRING_SIZE_CONST_STRING_VAR,
+               ATTR_FORMAT_PRINTF_3_4)
+DEF_LIB_BUILTIN(BUILT_IN_SPRINTF,
+               "__builtin_sprintf",
+               BT_FN_INT_STRING_CONST_STRING_VAR,
+               ATTR_FORMAT_PRINTF_2_3)
+DEF_LIB_BUILTIN(BUILT_IN_SCANF,
+               "__builtin_scanf",
+               BT_FN_INT_CONST_STRING_VAR,
+               ATTR_FORMAT_SCANF_1_2)
+DEF_LIB_BUILTIN(BUILT_IN_SSCANF,
+               "__builtin_sscanf",
+               BT_FN_INT_CONST_STRING_CONST_STRING_VAR,
+               ATTR_FORMAT_SCANF_2_3)
+DEF_LIB_BUILTIN(BUILT_IN_VPRINTF,
+               "__builtin_vprintf",
+               BT_FN_INT_CONST_STRING_VALIST_ARG,
+               ATTR_FORMAT_PRINTF_1_0)
+DEF_C99_BUILTIN(BUILT_IN_VSCANF,
+               "__builtin_vscanf",
+               BT_FN_INT_CONST_STRING_VALIST_ARG,
+               ATTR_FORMAT_SCANF_1_0)
+DEF_C99_BUILTIN(BUILT_IN_VSSCANF,
+               "__builtin_vsscanf",
+               BT_FN_INT_CONST_STRING_CONST_STRING_VALIST_ARG,
+               ATTR_FORMAT_SCANF_2_0)
+DEF_C99_BUILTIN(BUILT_IN_VSNPRINTF,
+               "__builtin_vsnprintf",
+               BT_FN_INT_STRING_SIZE_CONST_STRING_VALIST_ARG,
+               ATTR_FORMAT_PRINTF_3_0)
+DEF_LIB_BUILTIN(BUILT_IN_VSPRINTF,
+               "__builtin_vsprintf",
+               BT_FN_INT_STRING_CONST_STRING_VALIST_ARG,
+               ATTR_FORMAT_PRINTF_2_0)
+
+
+/* stdio.h builtins (with FILE *).  */
+
 /* Declare the __builtin_ style with arguments and the regular style
    without them.  We rely on stdio.h to supply the arguments for the
    regular style declaration since we had to use void* instead of
    FILE* in the __builtin_ prototype supplied here.  */
+
+DEF_FALLBACK_BUILTIN(BUILT_IN_FPUTC,
+                    "__builtin_fputc",
+                    BT_FN_INT_INT_PTR,
+                    ATTR_NOTHROW_LIST)
 DEF_BUILTIN (BUILT_IN_FPUTS,
             "__builtin_fputs",
             BUILT_IN_NORMAL,
@@ -747,7 +789,7 @@ DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF,
                         BT_FN_INT_PTR_CONST_STRING_VAR,
                         ATTR_FORMAT_PRINTF_2_3)
 
-/* Stdio unlocked builtins.  */
+/* stdio unlocked builtins (without FILE *).  */
 
 DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR_UNLOCKED,
                         "__builtin_putchar_unlocked",
@@ -759,13 +801,17 @@ DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF_UNLOCKED,
                              "__builtin_printf_unlocked",
                              BT_FN_INT_CONST_STRING_VAR,
                              ATTR_FORMAT_PRINTF_1_2)
-DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FPUTC_UNLOCKED,
-                        "__builtin_fputc_unlocked",
-                        BT_FN_INT_INT_PTR)
+
+/* stdio unlocked builtins (with FILE *).  */
+
 /* Declare the __builtin_ style with arguments and the regular style
    without them.  We rely on stdio.h to supply the arguments for the
    regular style declaration since we had to use void* instead of
    FILE* in the __builtin_ prototype supplied here.  */
+
+DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FPUTC_UNLOCKED,
+                        "__builtin_fputc_unlocked",
+                        BT_FN_INT_INT_PTR)
 DEF_BUILTIN (BUILT_IN_FPUTS_UNLOCKED,
             "__builtin_fputs_unlocked",
             BUILT_IN_NORMAL,
index b49dc25f43dd7ffab4b7408d2273112dc7d9a361..1a20b474fca84e45bf8bc545f63031381e5642f8 100644 (file)
@@ -3203,6 +3203,7 @@ c_common_nodes_and_builtins ()
 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
+#define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
 #include "builtin-types.def"
 #undef DEF_PRIMITIVE_TYPE
@@ -3214,6 +3215,7 @@ c_common_nodes_and_builtins ()
 #undef DEF_FUNCTION_TYPE_VAR_0
 #undef DEF_FUNCTION_TYPE_VAR_1
 #undef DEF_FUNCTION_TYPE_VAR_2
+#undef DEF_FUNCTION_TYPE_VAR_3
 #undef DEF_POINTER_TYPE
     BT_LAST
   };
@@ -3533,6 +3535,19 @@ c_common_nodes_and_builtins ()
                  tree_cons (NULL_TREE,                         \
                             builtin_types[(int) ARG2],         \
                             NULL_TREE)));
+
+#define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3)                \
+   builtin_types[(int) ENUM]                                           \
+    = build_function_type                                              \
+      (builtin_types[(int) RETURN],                                    \
+       tree_cons (NULL_TREE,                                           \
+                 builtin_types[(int) ARG1],                            \
+                 tree_cons (NULL_TREE,                                 \
+                            builtin_types[(int) ARG2],                 \
+                            tree_cons (NULL_TREE,                      \
+                                       builtin_types[(int) ARG3],      \
+                                       NULL_TREE))));
+
 #define DEF_POINTER_TYPE(ENUM, TYPE)                   \
   builtin_types[(int) ENUM]                            \
     = build_pointer_type (builtin_types[(int) TYPE]);
@@ -3544,6 +3559,8 @@ c_common_nodes_and_builtins ()
 #undef DEF_FUNCTION_TYPE_4
 #undef DEF_FUNCTION_TYPE_VAR_0
 #undef DEF_FUNCTION_TYPE_VAR_1
+#undef DEF_FUNCTION_TYPE_VAR_2
+#undef DEF_FUNCTION_TYPE_VAR_3
 #undef DEF_POINTER_TYPE
 
   if (!c_attrs_initialized)
index e148c2f046c01ac2aa3824c8c6d855555152b5f9..a74c7513bb57412bed2f325a602b14569c041daf 100644 (file)
@@ -4591,16 +4591,22 @@ v4si f (v4si a, v4si b, v4si c)
 @findex powl
 @findex printf
 @findex printf_unlocked
+@findex putchar
+@findex puts
 @findex rindex
 @findex round
 @findex roundf
 @findex roundl
+@findex scanf
 @findex sin
 @findex sinf
 @findex sinl
+@findex snprintf
+@findex sprintf
 @findex sqrt
 @findex sqrtf
 @findex sqrtl
+@findex sscanf
 @findex strcat
 @findex strchr
 @findex strcmp
@@ -4617,6 +4623,11 @@ v4si f (v4si a, v4si b, v4si c)
 @findex trunc
 @findex truncf
 @findex truncl
+@findex vprintf
+@findex vscanf
+@findex vsnprintf
+@findex vsprintf
+@findex vsscanf
 
 GCC provides a large number of built-in functions other than the ones
 mentioned above.  Some of these are for internal use in the processing
@@ -4648,10 +4659,12 @@ mode.
 
 The ISO C99 functions @code{conj}, @code{conjf}, @code{conjl}, @code{creal},
 @code{crealf}, @code{creall}, @code{cimag}, @code{cimagf}, @code{cimagl},
-@code{_Exit},
-@code{llabs}, @code{imaxabs}, @code{round}, @code{roundf}, @code{roundl},
-@code{trunc}, @code{truncf}, @code{truncl}, @code{nearbyint},
-@code{nearbyintf} and @code{nearbyintl} are handled as built-in functions
+@code{_Exit}, @code{imaxabs}, @code{llabs},
+@code{nearbyint}, @code{nearbyintf}, @code{nearbyintl},
+@code{round}, @code{roundf}, @code{roundl}, @code{snprintf},
+@code{trunc}, @code{truncf}, @code{truncl},
+@code{vscanf}, @code{vsnprintf} and @code{vsscanf}
+are handled as built-in functions
 except in strict ISO C90 mode (@option{-ansi} or @option{-std=c89}).
 
 There are also built-in versions of the ISO C99 functions @code{atan2f},
@@ -4669,10 +4682,13 @@ The ISO C90 functions @code{abort}, @code{abs}, @code{atan2}, @code{ceil},
 @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
 @code{fprintf}, @code{fputs}, @code{labs}, @code{log},
 @code{memcmp}, @code{memcpy}, @code{memset}, @code{pow}, @code{printf},
-@code{sin}, @code{sqrt}, @code{strcat}, @code{strchr}, @code{strcmp},
+@code{putchar}, @code{puts}, @code{scanf}, @code{sin}, @code{snprintf},
+@code{sprintf}, code{sqrt}, @code{sscanf},
+@code{strcat}, @code{strchr}, @code{strcmp},
 @code{strcpy}, @code{strcspn}, @code{strlen}, @code{strncat}, @code{strncmp},
-@code{strncpy}, @code{strpbrk}, @code{strrchr}, @code{strspn}, and
-@code{strstr} are all recognized as built-in functions unless
+@code{strncpy}, @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
+@code{vprintf} and @code{vsprintf}
+are all recognized as built-in functions unless
 @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
 is specified for an individual function).  All of these functions have
 corresponding versions prefixed with @code{__builtin_}.
index 3bd47c7311f9f8763fec2108adb7c5134ac9ece6..31bd3a4dc8053517d2bc6ccf7ba29eb9bc697492 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-01  Roger Sayle  <roger@eyesopen.com>
+
+       * java/builtins.c (builtin_type): Handle DEF_FUNCTION_TYPE_VAR_3.
+       (initialize_builtins): Handle DEF_FUNCTION_TYPE_VAR_3.
+
 2003-03-01  Tom Tromey  <tromey@redhat.com>
 
        * parse.y (jdep_resolve_class): Only check deprecation if we found
index 1e388d887e1c2386dcc3972b6496c7d4585b112a..4c9a83a9dd500500d4eb96da8548c8a919878d4a 100644 (file)
@@ -46,6 +46,7 @@ enum builtin_type
 #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
 #define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) NAME,
 #define DEF_FUNCTION_TYPE_VAR_2(NAME, RETURN, ARG1, ARG2) NAME,
+#define DEF_FUNCTION_TYPE_VAR_3(NAME, RETURN, ARG1, ARG2, ARG3) NAME,
 #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
 #include "builtin-types.def"
 #undef DEF_PRIMITIVE_TYPE
@@ -57,6 +58,7 @@ enum builtin_type
 #undef DEF_FUNCTION_TYPE_VAR_0
 #undef DEF_FUNCTION_TYPE_VAR_1
 #undef DEF_FUNCTION_TYPE_VAR_2
+#undef DEF_FUNCTION_TYPE_VAR_3
 #undef DEF_POINTER_TYPE
   BT_LAST
 };
@@ -297,12 +299,14 @@ initialize_builtins (void)
 #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4)      \
   builtin_types[(int) ENUM]                                            \
     = define_builtin_type (RETURN, ARG1, ARG2, ARG3, ARG4);
-#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN)                                \
+#define DEF_FUNCTION_TYPE_VAR_0(ENUM, RETURN)                  \
   builtin_types[(int) ENUM] = NULL_TREE;
-#define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1)                     \
+#define DEF_FUNCTION_TYPE_VAR_1(ENUM, RETURN, ARG1)            \
    builtin_types[(int) ENUM] = NULL_TREE;
 #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2)      \
    builtin_types[(int) ENUM] = NULL_TREE;
+#define DEF_FUNCTION_TYPE_VAR_3(ENUM, RETURN, ARG1, ARG2, ARG3)        \
+   builtin_types[(int) ENUM] = NULL_TREE;
 #define DEF_POINTER_TYPE(ENUM, TYPE)                   \
   builtin_types[(int) ENUM] = NULL_TREE;
 
index 9925bd233d0b292826f29caaf12574dba4e9ad50..e7aa1e6eae99beddb3f874d0f82cb31d8a1d639a 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-01  Roger Sayle  <roger@eyesopen.com>
+
+       * g++.old-deja/g++.other/builtins10.C: New test for PR 9367.
+       * gcc.dg/format/attr-5.c: Handle new conflicting types warning.
+
 2003-03-01  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * g++.dg/warn/implicit-typename1.C: Remove warning.
diff --git a/gcc/testsuite/g++.old-deja/g++.other/builtins10.C b/gcc/testsuite/g++.old-deja/g++.other/builtins10.C
new file mode 100644 (file)
index 0000000..0fa5980
--- /dev/null
@@ -0,0 +1,7 @@
+// Build don't link:
+// Test that built-in functions don't warn when prototyped without arguments.
+// Origin: PR c++/9367
+// Copyright (C) 2003 Free Software Foundation.
+
+extern "C" int snprintf();
+
index a4e96344b6109db64a538e3e4475f1c21f49d374..36b1198968744b1f6bc0a00fa5daab78db3f5de9 100644 (file)
@@ -11,7 +11,7 @@ static int scanf(const char *restrict, ...);
 
 /* This sscanf declaration doesn't have variable arguments, so isn't
    compatible with a format attribute.  */
-extern int sscanf(const char *restrict, const char *restrict, int *);
+extern int sscanf(const char *restrict, const char *restrict, int *); /* { dg-warning "conflict" "conflict" } */
 
 void
 foo (const char *s, int *p)