From 082916584969704a8b996bdbd0ea353a3b742bd3 Mon Sep 17 00:00:00 2001 From: Roger Sayle Date: Sun, 2 Mar 2003 01:34:34 +0000 Subject: [PATCH] re PR c++/9367 (error: nonnull argument with extern "C" snprintf prototype) 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 | 23 +++++++ gcc/builtin-attrs.def | 18 ++--- gcc/builtin-types.def | 19 +++++- gcc/builtins.def | 80 ++++++++++++++++++----- gcc/c-common.c | 17 +++++ gcc/doc/extend.texi | 30 +++++++-- gcc/java/ChangeLog | 5 ++ gcc/java/builtins.c | 8 ++- gcc/testsuite/ChangeLog | 5 ++ gcc/testsuite/g++.old-deja/g++.other/builtins10.C | 7 ++ gcc/testsuite/gcc.dg/format/attr-5.c | 2 +- 11 files changed, 174 insertions(+), 40 deletions(-) create mode 100644 gcc/testsuite/g++.old-deja/g++.other/builtins10.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fdd350d..61dca7e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2003-03-01 Roger Sayle + + 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 * config/h8300/h8300.md (a peephole2): New. diff --git a/gcc/builtin-attrs.def b/gcc/builtin-attrs.def index b307151..7bdbd62 100644 --- a/gcc/builtin-attrs.def +++ b/gcc/builtin-attrs.def @@ -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. */ diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def index 9fa0f4e..c095d07 100644 --- a/gcc/builtin-types.def +++ b/gcc/builtin-types.def @@ -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, diff --git a/gcc/builtins.def b/gcc/builtins.def index ae7d640..48fd197 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -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, diff --git a/gcc/c-common.c b/gcc/c-common.c index b49dc25..1a20b47 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -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) diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index e148c2f..a74c751 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -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_}. diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 3bd47c7..31bd3a4 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,8 @@ +2003-03-01 Roger Sayle + + * java/builtins.c (builtin_type): Handle DEF_FUNCTION_TYPE_VAR_3. + (initialize_builtins): Handle DEF_FUNCTION_TYPE_VAR_3. + 2003-03-01 Tom Tromey * parse.y (jdep_resolve_class): Only check deprecation if we found diff --git a/gcc/java/builtins.c b/gcc/java/builtins.c index 1e388d8..4c9a83a 100644 --- a/gcc/java/builtins.c +++ b/gcc/java/builtins.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9925bd2..e7aa1e6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2003-03-01 Roger Sayle + + * 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 * 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 index 0000000..0fa5980 --- /dev/null +++ b/gcc/testsuite/g++.old-deja/g++.other/builtins10.C @@ -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(); + diff --git a/gcc/testsuite/gcc.dg/format/attr-5.c b/gcc/testsuite/gcc.dg/format/attr-5.c index a4e9634..36b1198 100644 --- a/gcc/testsuite/gcc.dg/format/attr-5.c +++ b/gcc/testsuite/gcc.dg/format/attr-5.c @@ -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) -- 2.7.4