Commit 08291658 by Roger Sayle Committed by Roger Sayle

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
parent 66c4e258
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> 2003-03-01 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.md (a peephole2): New. * config/h8300/h8300.md (a peephole2): New.
......
...@@ -102,9 +102,12 @@ DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \ ...@@ -102,9 +102,12 @@ DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \
DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \ DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_LIST, ATTR_MALLOC, \
ATTR_NULL, ATTR_NOTHROW_LIST) 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_1, ATTR_NONNULL, ATTR_LIST_1, \
DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, ATTR_NULL) ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, ATTR_NULL) 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. */ /* Construct a tree for a format attribute. */
#define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \ #define DEF_FORMAT_ATTRIBUTE(TYPE, FA, VALUES) \
...@@ -149,13 +152,8 @@ DEF_FORMAT_ARG_ATTRIBUTE(2) ...@@ -149,13 +152,8 @@ DEF_FORMAT_ARG_ATTRIBUTE(2)
/* Functions from ISO/IEC 9899:1990. */ /* Functions from ISO/IEC 9899:1990. */
#define DEF_C89_ATTR(NAME, ATTRS) DEF_FN_ATTR_IDENT (NAME, ATTRS, flag_hosted) #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 (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 (vfprintf, ATTR_FORMAT_PRINTF_2_0)
DEF_C89_ATTR (vsprintf, ATTR_FORMAT_PRINTF_2_0)
DEF_C89_ATTR (strftime, ATTR_FORMAT_STRFTIME_3_0) DEF_C89_ATTR (strftime, ATTR_FORMAT_STRFTIME_3_0)
#undef DEF_C89_ATTR #undef DEF_C89_ATTR
...@@ -164,11 +162,7 @@ DEF_C89_ATTR (strftime, ATTR_FORMAT_STRFTIME_3_0) ...@@ -164,11 +162,7 @@ DEF_C89_ATTR (strftime, ATTR_FORMAT_STRFTIME_3_0)
DEF_FN_ATTR_IDENT (NAME, ATTRS, \ DEF_FN_ATTR_IDENT (NAME, ATTRS, \
(flag_hosted \ (flag_hosted \
&& (flag_isoc99 || flag_noniso_default_format_attributes))) && (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 (vfscanf, ATTR_FORMAT_SCANF_2_0)
DEF_C99_ATTR (vsscanf, ATTR_FORMAT_SCANF_2_0)
#undef DEF_C99_ATTR #undef DEF_C99_ATTR
/* Functions not in any version of ISO C. */ /* Functions not in any version of ISO C. */
......
...@@ -40,6 +40,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -40,6 +40,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
DEF_FUNCTION_TYPE_VAR_0 (ENUM, RETURN) DEF_FUNCTION_TYPE_VAR_0 (ENUM, RETURN)
DEF_FUNCTION_TYPE_VAR_1 (ENUM, RETURN, ARG1) DEF_FUNCTION_TYPE_VAR_1 (ENUM, RETURN, ARG1)
DEF_FUNCTION_TYPE_VAR_2 (ENUM, RETURN, ARG1, ARG2) 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. Similar, but for function types that take variable arguments.
For example: For example:
...@@ -155,6 +156,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_DOUBLE, ...@@ -155,6 +156,8 @@ DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_DOUBLE,
BT_DOUBLE, BT_DOUBLE, BT_DOUBLE) BT_DOUBLE, BT_DOUBLE, BT_DOUBLE)
DEF_FUNCTION_TYPE_2 (BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE, DEF_FUNCTION_TYPE_2 (BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
BT_LONG_DOUBLE, BT_LONG_DOUBLE, BT_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, DEF_FUNCTION_TYPE_3 (BT_FN_STRING_STRING_CONST_STRING_SIZE,
BT_STRING, BT_STRING, BT_CONST_STRING, BT_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, ...@@ -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) BT_INT, BT_CONST_PTR, BT_CONST_PTR, BT_SIZE)
DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_INT_SIZE, DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_INT_SIZE,
BT_PTR, BT_PTR, BT_INT, BT_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, DEF_FUNCTION_TYPE_4 (BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR,
BT_SIZE, BT_CONST_PTR, BT_SIZE, BT_SIZE, BT_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_VOID_VAR, BT_VOID)
DEF_FUNCTION_TYPE_VAR_0 (BT_FN_INT_VAR, BT_INT) 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, ...@@ -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, DEF_FUNCTION_TYPE_VAR_2 (BT_FN_INT_PTR_CONST_STRING_VAR,
BT_INT, BT_PTR, BT_CONST_STRING) 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_POINTER_TYPE (BT_PTR_FN_VOID_VAR, BT_FN_VOID_VAR)
DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE, DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE,
......
...@@ -711,27 +711,69 @@ DEF_GCC_BUILTIN(BUILT_IN_PREFETCH, ...@@ -711,27 +711,69 @@ DEF_GCC_BUILTIN(BUILT_IN_PREFETCH,
BT_FN_VOID_CONST_PTR_VAR, BT_FN_VOID_CONST_PTR_VAR,
ATTR_NULL) ATTR_NULL)
/* Stdio builtins. */ /* stdio.h builtins (without FILE *). */
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)
DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF, DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF,
"__builtin_printf", "__builtin_printf",
BT_FN_INT_CONST_STRING_VAR, BT_FN_INT_CONST_STRING_VAR,
ATTR_FORMAT_PRINTF_1_2) ATTR_FORMAT_PRINTF_1_2)
DEF_FALLBACK_BUILTIN(BUILT_IN_FPUTC, DEF_LIB_BUILTIN(BUILT_IN_PUTCHAR,
"__builtin_fputc", "__builtin_putchar",
BT_FN_INT_INT_PTR, BT_FN_INT_INT,
ATTR_NOTHROW_LIST) 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 /* Declare the __builtin_ style with arguments and the regular style
without them. We rely on stdio.h to supply the arguments for the without them. We rely on stdio.h to supply the arguments for the
regular style declaration since we had to use void* instead of regular style declaration since we had to use void* instead of
FILE* in the __builtin_ prototype supplied here. */ 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, DEF_BUILTIN (BUILT_IN_FPUTS,
"__builtin_fputs", "__builtin_fputs",
BUILT_IN_NORMAL, BUILT_IN_NORMAL,
...@@ -747,7 +789,7 @@ DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF, ...@@ -747,7 +789,7 @@ DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF,
BT_FN_INT_PTR_CONST_STRING_VAR, BT_FN_INT_PTR_CONST_STRING_VAR,
ATTR_FORMAT_PRINTF_2_3) ATTR_FORMAT_PRINTF_2_3)
/* Stdio unlocked builtins. */ /* stdio unlocked builtins (without FILE *). */
DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR_UNLOCKED, DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR_UNLOCKED,
"__builtin_putchar_unlocked", "__builtin_putchar_unlocked",
...@@ -759,13 +801,17 @@ DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF_UNLOCKED, ...@@ -759,13 +801,17 @@ DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF_UNLOCKED,
"__builtin_printf_unlocked", "__builtin_printf_unlocked",
BT_FN_INT_CONST_STRING_VAR, BT_FN_INT_CONST_STRING_VAR,
ATTR_FORMAT_PRINTF_1_2) ATTR_FORMAT_PRINTF_1_2)
DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FPUTC_UNLOCKED,
"__builtin_fputc_unlocked", /* stdio unlocked builtins (with FILE *). */
BT_FN_INT_INT_PTR)
/* Declare the __builtin_ style with arguments and the regular style /* Declare the __builtin_ style with arguments and the regular style
without them. We rely on stdio.h to supply the arguments for the without them. We rely on stdio.h to supply the arguments for the
regular style declaration since we had to use void* instead of regular style declaration since we had to use void* instead of
FILE* in the __builtin_ prototype supplied here. */ 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, DEF_BUILTIN (BUILT_IN_FPUTS_UNLOCKED,
"__builtin_fputs_unlocked", "__builtin_fputs_unlocked",
BUILT_IN_NORMAL, BUILT_IN_NORMAL,
......
...@@ -3203,6 +3203,7 @@ c_common_nodes_and_builtins () ...@@ -3203,6 +3203,7 @@ c_common_nodes_and_builtins ()
#define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME, #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
#define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) 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_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, #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
#include "builtin-types.def" #include "builtin-types.def"
#undef DEF_PRIMITIVE_TYPE #undef DEF_PRIMITIVE_TYPE
...@@ -3214,6 +3215,7 @@ c_common_nodes_and_builtins () ...@@ -3214,6 +3215,7 @@ c_common_nodes_and_builtins ()
#undef DEF_FUNCTION_TYPE_VAR_0 #undef DEF_FUNCTION_TYPE_VAR_0
#undef DEF_FUNCTION_TYPE_VAR_1 #undef DEF_FUNCTION_TYPE_VAR_1
#undef DEF_FUNCTION_TYPE_VAR_2 #undef DEF_FUNCTION_TYPE_VAR_2
#undef DEF_FUNCTION_TYPE_VAR_3
#undef DEF_POINTER_TYPE #undef DEF_POINTER_TYPE
BT_LAST BT_LAST
}; };
...@@ -3533,6 +3535,19 @@ c_common_nodes_and_builtins () ...@@ -3533,6 +3535,19 @@ c_common_nodes_and_builtins ()
tree_cons (NULL_TREE, \ tree_cons (NULL_TREE, \
builtin_types[(int) ARG2], \ builtin_types[(int) ARG2], \
NULL_TREE))); 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) \ #define DEF_POINTER_TYPE(ENUM, TYPE) \
builtin_types[(int) ENUM] \ builtin_types[(int) ENUM] \
= build_pointer_type (builtin_types[(int) TYPE]); = build_pointer_type (builtin_types[(int) TYPE]);
...@@ -3544,6 +3559,8 @@ c_common_nodes_and_builtins () ...@@ -3544,6 +3559,8 @@ c_common_nodes_and_builtins ()
#undef DEF_FUNCTION_TYPE_4 #undef DEF_FUNCTION_TYPE_4
#undef DEF_FUNCTION_TYPE_VAR_0 #undef DEF_FUNCTION_TYPE_VAR_0
#undef DEF_FUNCTION_TYPE_VAR_1 #undef DEF_FUNCTION_TYPE_VAR_1
#undef DEF_FUNCTION_TYPE_VAR_2
#undef DEF_FUNCTION_TYPE_VAR_3
#undef DEF_POINTER_TYPE #undef DEF_POINTER_TYPE
if (!c_attrs_initialized) if (!c_attrs_initialized)
......
...@@ -4591,16 +4591,22 @@ v4si f (v4si a, v4si b, v4si c) ...@@ -4591,16 +4591,22 @@ v4si f (v4si a, v4si b, v4si c)
@findex powl @findex powl
@findex printf @findex printf
@findex printf_unlocked @findex printf_unlocked
@findex putchar
@findex puts
@findex rindex @findex rindex
@findex round @findex round
@findex roundf @findex roundf
@findex roundl @findex roundl
@findex scanf
@findex sin @findex sin
@findex sinf @findex sinf
@findex sinl @findex sinl
@findex snprintf
@findex sprintf
@findex sqrt @findex sqrt
@findex sqrtf @findex sqrtf
@findex sqrtl @findex sqrtl
@findex sscanf
@findex strcat @findex strcat
@findex strchr @findex strchr
@findex strcmp @findex strcmp
...@@ -4617,6 +4623,11 @@ v4si f (v4si a, v4si b, v4si c) ...@@ -4617,6 +4623,11 @@ v4si f (v4si a, v4si b, v4si c)
@findex trunc @findex trunc
@findex truncf @findex truncf
@findex truncl @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 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 mentioned above. Some of these are for internal use in the processing
...@@ -4648,10 +4659,12 @@ mode. ...@@ -4648,10 +4659,12 @@ mode.
The ISO C99 functions @code{conj}, @code{conjf}, @code{conjl}, @code{creal}, The ISO C99 functions @code{conj}, @code{conjf}, @code{conjl}, @code{creal},
@code{crealf}, @code{creall}, @code{cimag}, @code{cimagf}, @code{cimagl}, @code{crealf}, @code{creall}, @code{cimag}, @code{cimagf}, @code{cimagl},
@code{_Exit}, @code{_Exit}, @code{imaxabs}, @code{llabs},
@code{llabs}, @code{imaxabs}, @code{round}, @code{roundf}, @code{roundl}, @code{nearbyint}, @code{nearbyintf}, @code{nearbyintl},
@code{trunc}, @code{truncf}, @code{truncl}, @code{nearbyint}, @code{round}, @code{roundf}, @code{roundl}, @code{snprintf},
@code{nearbyintf} and @code{nearbyintl} are handled as built-in functions @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}). 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}, 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}, ...@@ -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{exp}, @code{fabs}, @code{floor}, @code{fmod},
@code{fprintf}, @code{fputs}, @code{labs}, @code{log}, @code{fprintf}, @code{fputs}, @code{labs}, @code{log},
@code{memcmp}, @code{memcpy}, @code{memset}, @code{pow}, @code{printf}, @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{strcpy}, @code{strcspn}, @code{strlen}, @code{strncat}, @code{strncmp},
@code{strncpy}, @code{strpbrk}, @code{strrchr}, @code{strspn}, and @code{strncpy}, @code{strpbrk}, @code{strrchr}, @code{strspn}, @code{strstr},
@code{strstr} are all recognized as built-in functions unless @code{vprintf} and @code{vsprintf}
are all recognized as built-in functions unless
@option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}} @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
is specified for an individual function). All of these functions have is specified for an individual function). All of these functions have
corresponding versions prefixed with @code{__builtin_}. corresponding versions prefixed with @code{__builtin_}.
......
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> 2003-03-01 Tom Tromey <tromey@redhat.com>
* parse.y (jdep_resolve_class): Only check deprecation if we found * parse.y (jdep_resolve_class): Only check deprecation if we found
......
...@@ -46,6 +46,7 @@ enum builtin_type ...@@ -46,6 +46,7 @@ enum builtin_type
#define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME, #define DEF_FUNCTION_TYPE_VAR_0(NAME, RETURN) NAME,
#define DEF_FUNCTION_TYPE_VAR_1(NAME, RETURN, ARG1) 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_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, #define DEF_POINTER_TYPE(NAME, TYPE) NAME,
#include "builtin-types.def" #include "builtin-types.def"
#undef DEF_PRIMITIVE_TYPE #undef DEF_PRIMITIVE_TYPE
...@@ -57,6 +58,7 @@ enum builtin_type ...@@ -57,6 +58,7 @@ enum builtin_type
#undef DEF_FUNCTION_TYPE_VAR_0 #undef DEF_FUNCTION_TYPE_VAR_0
#undef DEF_FUNCTION_TYPE_VAR_1 #undef DEF_FUNCTION_TYPE_VAR_1
#undef DEF_FUNCTION_TYPE_VAR_2 #undef DEF_FUNCTION_TYPE_VAR_2
#undef DEF_FUNCTION_TYPE_VAR_3
#undef DEF_POINTER_TYPE #undef DEF_POINTER_TYPE
BT_LAST BT_LAST
}; };
...@@ -297,12 +299,14 @@ initialize_builtins (void) ...@@ -297,12 +299,14 @@ initialize_builtins (void)
#define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \ #define DEF_FUNCTION_TYPE_4(ENUM, RETURN, ARG1, ARG2, ARG3, ARG4) \
builtin_types[(int) ENUM] \ builtin_types[(int) ENUM] \
= define_builtin_type (RETURN, ARG1, ARG2, ARG3, ARG4); = 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; 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; builtin_types[(int) ENUM] = NULL_TREE;
#define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \ #define DEF_FUNCTION_TYPE_VAR_2(ENUM, RETURN, ARG1, ARG2) \
builtin_types[(int) ENUM] = NULL_TREE; 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) \ #define DEF_POINTER_TYPE(ENUM, TYPE) \
builtin_types[(int) ENUM] = NULL_TREE; builtin_types[(int) ENUM] = NULL_TREE;
......
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> 2003-03-01 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
* g++.dg/warn/implicit-typename1.C: Remove warning. * g++.dg/warn/implicit-typename1.C: Remove warning.
......
// 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();
...@@ -11,7 +11,7 @@ static int scanf(const char *restrict, ...); ...@@ -11,7 +11,7 @@ static int scanf(const char *restrict, ...);
/* This sscanf declaration doesn't have variable arguments, so isn't /* This sscanf declaration doesn't have variable arguments, so isn't
compatible with a format attribute. */ 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 void
foo (const char *s, int *p) foo (const char *s, int *p)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment