Commit 00362064 by Kaveh R. Ghazi Committed by Kaveh Ghazi

builtin-attrs.def (ATTR_NOTHROW_NONNULL_1, [...]): Renamed from ATTR_NONNULL_1,…

builtin-attrs.def (ATTR_NOTHROW_NONNULL_1, [...]): Renamed from ATTR_NONNULL_1, ATTR_NONNULL_2 and ATTR_NONNULL_3.

gcc:
	* builtin-attrs.def (ATTR_NOTHROW_NONNULL_1,
	ATTR_NOTHROW_NONNULL_2, ATTR_NOTHROW_NONNULL_3): Renamed from
	ATTR_NONNULL_1, ATTR_NONNULL_2 and ATTR_NONNULL_3.

	(ATTR_NOTHROW_NONNULL_1_2, ATTR_NOTHROW_NONNULL_1_4,
	ATTR_CONST_NOTHROW_NONNULL_1, ATTR_PURE_NOTHROW_NONNULL_1,
	ATTR_PURE_NOTHROW_NONNULL_1_2, ATTR_MALLOC_NOTHROW_NONNULL_1):
	New.

	* builtins.def (DEF_EXT_FALLBACK_BUILTIN): Accept ATTRS argument.
	(BUILT_IN_BZERO, BUILT_IN_BCOPY, BUILT_IN_BCMP): Update comment

	(BUILT_IN_INDEX, BUILT_IN_RINDEX, BUILT_IN_MEMCPY,
	BUILT_IN_MEMMOVE, BUILT_IN_MEMCMP, BUILT_IN_MEMSET,
	BUILT_IN_MEMPCPY, BUILT_IN_STRCAT, BUILT_IN_STRNCAT,
	BUILT_IN_STPCPY, BUILT_IN_STRCPY, BUILT_IN_STRNCPY,
	BUILT_IN_STRCMP, BUILT_IN_STRNCMP, BUILT_IN_STRLEN,
	BUILT_IN_STRSTR, BUILT_IN_STRPBRK, BUILT_IN_STRSPN,
	BUILT_IN_STRCSPN, BUILT_IN_STRCHR, BUILT_IN_STRRCHR, BUILT_IN_NAN,
	BUILT_IN_NANF, BUILT_IN_NANL, BUILT_IN_NANS, BUILT_IN_NANSF,
	BUILT_IN_NANSL, BUILT_IN_PUTS, BUILT_IN_FPUTC, BUILT_IN_FPUTS,
	BUILT_IN_FWRITE, BUILT_IN_PUTS_UNLOCKED, BUILT_IN_FPUTC_UNLOCKED,
	BUILT_IN_FPUTS_UNLOCKED, BUILT_IN_FWRITE_UNLOCKED,
	BUILT_IN_STRDUP): Add "nonnull" attribute.

testsuite:
	* gcc.dg/nonnull-3.c: New test.

From-SVN: r66468
parent 05c30f22
2003-05-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtin-attrs.def (ATTR_NOTHROW_NONNULL_1,
ATTR_NOTHROW_NONNULL_2, ATTR_NOTHROW_NONNULL_3): Renamed from
ATTR_NONNULL_1, ATTR_NONNULL_2 and ATTR_NONNULL_3.
(ATTR_NOTHROW_NONNULL_1_2, ATTR_NOTHROW_NONNULL_1_4,
ATTR_CONST_NOTHROW_NONNULL_1, ATTR_PURE_NOTHROW_NONNULL_1,
ATTR_PURE_NOTHROW_NONNULL_1_2, ATTR_MALLOC_NOTHROW_NONNULL_1):
New.
* builtins.def (DEF_EXT_FALLBACK_BUILTIN): Accept ATTRS argument.
(BUILT_IN_BZERO, BUILT_IN_BCOPY, BUILT_IN_BCMP): Update comment
(BUILT_IN_INDEX, BUILT_IN_RINDEX, BUILT_IN_MEMCPY,
BUILT_IN_MEMMOVE, BUILT_IN_MEMCMP, BUILT_IN_MEMSET,
BUILT_IN_MEMPCPY, BUILT_IN_STRCAT, BUILT_IN_STRNCAT,
BUILT_IN_STPCPY, BUILT_IN_STRCPY, BUILT_IN_STRNCPY,
BUILT_IN_STRCMP, BUILT_IN_STRNCMP, BUILT_IN_STRLEN,
BUILT_IN_STRSTR, BUILT_IN_STRPBRK, BUILT_IN_STRSPN,
BUILT_IN_STRCSPN, BUILT_IN_STRCHR, BUILT_IN_STRRCHR, BUILT_IN_NAN,
BUILT_IN_NANF, BUILT_IN_NANL, BUILT_IN_NANS, BUILT_IN_NANSF,
BUILT_IN_NANSL, BUILT_IN_PUTS, BUILT_IN_FPUTC, BUILT_IN_FPUTS,
BUILT_IN_FWRITE, BUILT_IN_PUTS_UNLOCKED, BUILT_IN_FPUTC_UNLOCKED,
BUILT_IN_FPUTS_UNLOCKED, BUILT_IN_FWRITE_UNLOCKED,
BUILT_IN_STRDUP): Add "nonnull" attribute.
2003-05-04 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> 2003-05-04 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* expr.c (store_field): Don't clobber TEMP in shift: it might be * expr.c (store_field): Don't clobber TEMP in shift: it might be
......
...@@ -102,19 +102,37 @@ DEF_ATTR_TREE_LIST (ATTR_NORETURN_NOTHROW_LIST, ATTR_NORETURN, \ ...@@ -102,19 +102,37 @@ 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, \ DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1, ATTR_NONNULL, ATTR_LIST_1, \
ATTR_NOTHROW_LIST) ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \ DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_2, ATTR_NONNULL, ATTR_LIST_2, \
ATTR_NOTHROW_LIST) ATTR_NOTHROW_LIST)
DEF_ATTR_TREE_LIST (ATTR_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \ DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_3, ATTR_NONNULL, ATTR_LIST_3, \
ATTR_NOTHROW_LIST) ATTR_NOTHROW_LIST)
/* Nothrow functions whose first and second parameters are nonnull pointers. */
DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_2, ATTR_NONNULL, ATTR_LIST_2, \
ATTR_NOTHROW_NONNULL_1)
/* Nothrow functions whose first and fourth parameters are nonnull pointers. */
DEF_ATTR_TREE_LIST (ATTR_NOTHROW_NONNULL_1_4, ATTR_NONNULL, ATTR_LIST_4, \
ATTR_NOTHROW_NONNULL_1)
/* Nothrow const functions whose first parameter is a nonnull pointer. */
DEF_ATTR_TREE_LIST (ATTR_CONST_NOTHROW_NONNULL_1, ATTR_CONST, ATTR_NULL, \
ATTR_NOTHROW_NONNULL_1)
/* Nothrow pure functions whose first parameter is a nonnull pointer. */
DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_1, ATTR_PURE, ATTR_NULL, \
ATTR_NOTHROW_NONNULL_1)
/* Nothrow pure functions whose first and second parameters are nonnull pointers. */
DEF_ATTR_TREE_LIST (ATTR_PURE_NOTHROW_NONNULL_1_2, ATTR_PURE, ATTR_NULL, \
ATTR_NOTHROW_NONNULL_1_2)
/* Nothrow malloc functions whose first parameter is a nonnull pointer. */
DEF_ATTR_TREE_LIST (ATTR_MALLOC_NOTHROW_NONNULL_1, ATTR_MALLOC, ATTR_NULL, \
ATTR_NOTHROW_NONNULL_1)
/* 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) \
DEF_ATTR_TREE_LIST (CONCAT4 (ATTR_,TYPE,_,VALUES), ATTR_NULL, \ DEF_ATTR_TREE_LIST (CONCAT4 (ATTR_,TYPE,_,VALUES), ATTR_NULL, \
CONCAT2 (ATTR_,TYPE), CONCAT2 (ATTR_LIST_,VALUES)) \ CONCAT2 (ATTR_,TYPE), CONCAT2 (ATTR_LIST_,VALUES)) \
DEF_ATTR_TREE_LIST (CONCAT4 (ATTR_FORMAT_,TYPE,_,VALUES), ATTR_FORMAT, \ DEF_ATTR_TREE_LIST (CONCAT4 (ATTR_FORMAT_,TYPE,_,VALUES), ATTR_FORMAT, \
CONCAT4 (ATTR_,TYPE,_,VALUES), CONCAT2 (ATTR_NONNULL_,FA)) CONCAT4 (ATTR_,TYPE,_,VALUES), CONCAT2 (ATTR_NOTHROW_NONNULL_,FA))
DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0) DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_0)
DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2) DEF_FORMAT_ATTRIBUTE(PRINTF,1,1_2)
DEF_FORMAT_ATTRIBUTE(PRINTF,2,2_0) DEF_FORMAT_ATTRIBUTE(PRINTF,2,2_0)
...@@ -132,7 +150,7 @@ DEF_FORMAT_ATTRIBUTE(STRFMON,3,3_4) ...@@ -132,7 +150,7 @@ DEF_FORMAT_ATTRIBUTE(STRFMON,3,3_4)
/* Construct a tree for a format_arg attribute. */ /* Construct a tree for a format_arg attribute. */
#define DEF_FORMAT_ARG_ATTRIBUTE(FA) \ #define DEF_FORMAT_ARG_ATTRIBUTE(FA) \
DEF_ATTR_TREE_LIST (CONCAT2 (ATTR_FORMAT_ARG_,FA), ATTR_FORMAT_ARG, \ DEF_ATTR_TREE_LIST (CONCAT2 (ATTR_FORMAT_ARG_,FA), ATTR_FORMAT_ARG, \
CONCAT2 (ATTR_LIST_,FA), CONCAT2 (ATTR_NONNULL_,FA)) CONCAT2 (ATTR_LIST_,FA), CONCAT2 (ATTR_NOTHROW_NONNULL_,FA))
DEF_FORMAT_ARG_ATTRIBUTE(1) DEF_FORMAT_ARG_ATTRIBUTE(1)
DEF_FORMAT_ARG_ATTRIBUTE(2) DEF_FORMAT_ARG_ATTRIBUTE(2)
#undef DEF_FORMAT_ARG_ATTRIBUTE #undef DEF_FORMAT_ARG_ATTRIBUTE
......
...@@ -85,9 +85,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA ...@@ -85,9 +85,9 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
we ignore the version of these builtins that does not begin with we ignore the version of these builtins that does not begin with
__builtin. */ __builtin. */
#undef DEF_EXT_FALLBACK_BUILTIN #undef DEF_EXT_FALLBACK_BUILTIN
#define DEF_EXT_FALLBACK_BUILTIN(ENUM, NAME, TYPE) \ #define DEF_EXT_FALLBACK_BUILTIN(ENUM, NAME, TYPE, ATTRS) \
DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \
false, true, true, ATTR_NOTHROW_LIST, true) false, true, true, ATTRS, true)
/* A library builtin (like __builtin_strchr) is a builtin equivalent /* A library builtin (like __builtin_strchr) is a builtin equivalent
of an ANSI/ISO standard library function. In addition to the of an ANSI/ISO standard library function. In addition to the
...@@ -287,8 +287,11 @@ DEF_C99_BUILTIN(BUILT_IN_CIMAGL, ...@@ -287,8 +287,11 @@ DEF_C99_BUILTIN(BUILT_IN_CIMAGL,
ATTR_CONST_NOTHROW_LIST) ATTR_CONST_NOTHROW_LIST)
/* The system prototypes for `bzero', 'bcopy' and `bcmp' functions /* The system prototypes for `bzero', 'bcopy' and `bcmp' functions
have many variations, so don't specify parameters to avoid conflicts. have many variations, so don't specify parameters to avoid
The expand_* functions check the argument types anyway. */ conflicts. The expand_* functions check the argument types anyway.
In addition, these functions have traditionally accepted NULL
pointers when the length parameter is zero, so don't apply
attribute "nonnull". */
DEF_BUILTIN (BUILT_IN_BZERO, DEF_BUILTIN (BUILT_IN_BZERO,
"__builtin_bzero", "__builtin_bzero",
BUILT_IN_NORMAL, BUILT_IN_NORMAL,
...@@ -377,89 +380,89 @@ DEF_GCC_BUILTIN(BUILT_IN_PARITYLL, ...@@ -377,89 +380,89 @@ DEF_GCC_BUILTIN(BUILT_IN_PARITYLL,
DEF_EXT_LIB_BUILTIN(BUILT_IN_INDEX, DEF_EXT_LIB_BUILTIN(BUILT_IN_INDEX,
"__builtin_index", "__builtin_index",
BT_FN_STRING_CONST_STRING_INT, BT_FN_STRING_CONST_STRING_INT,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1)
DEF_EXT_LIB_BUILTIN(BUILT_IN_RINDEX, DEF_EXT_LIB_BUILTIN(BUILT_IN_RINDEX,
"__builtin_rindex", "__builtin_rindex",
BT_FN_STRING_CONST_STRING_INT, BT_FN_STRING_CONST_STRING_INT,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_MEMCPY, DEF_LIB_BUILTIN(BUILT_IN_MEMCPY,
"__builtin_memcpy", "__builtin_memcpy",
BT_FN_PTR_PTR_CONST_PTR_SIZE, BT_FN_PTR_PTR_CONST_PTR_SIZE,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_MEMMOVE, DEF_LIB_BUILTIN(BUILT_IN_MEMMOVE,
"__builtin_memmove", "__builtin_memmove",
BT_FN_PTR_PTR_CONST_PTR_SIZE, BT_FN_PTR_PTR_CONST_PTR_SIZE,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_MEMCMP, DEF_LIB_BUILTIN(BUILT_IN_MEMCMP,
"__builtin_memcmp", "__builtin_memcmp",
BT_FN_INT_CONST_PTR_CONST_PTR_SIZE, BT_FN_INT_CONST_PTR_CONST_PTR_SIZE,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_MEMSET, DEF_LIB_BUILTIN(BUILT_IN_MEMSET,
"__builtin_memset", "__builtin_memset",
BT_FN_PTR_PTR_INT_SIZE, BT_FN_PTR_PTR_INT_SIZE,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1)
DEF_EXT_LIB_BUILTIN(BUILT_IN_MEMPCPY, DEF_EXT_LIB_BUILTIN(BUILT_IN_MEMPCPY,
"__builtin_mempcpy", "__builtin_mempcpy",
BT_FN_PTR_PTR_CONST_PTR_SIZE, BT_FN_PTR_PTR_CONST_PTR_SIZE,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRCAT, DEF_LIB_BUILTIN(BUILT_IN_STRCAT,
"__builtin_strcat", "__builtin_strcat",
BT_FN_STRING_STRING_CONST_STRING, BT_FN_STRING_STRING_CONST_STRING,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRNCAT, DEF_LIB_BUILTIN(BUILT_IN_STRNCAT,
"__builtin_strncat", "__builtin_strncat",
BT_FN_STRING_STRING_CONST_STRING_SIZE, BT_FN_STRING_STRING_CONST_STRING_SIZE,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_2)
DEF_EXT_LIB_BUILTIN(BUILT_IN_STPCPY, DEF_EXT_LIB_BUILTIN(BUILT_IN_STPCPY,
"__builtin_stpcpy", "__builtin_stpcpy",
BT_FN_STRING_STRING_CONST_STRING, BT_FN_STRING_STRING_CONST_STRING,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRCPY, DEF_LIB_BUILTIN(BUILT_IN_STRCPY,
"__builtin_strcpy", "__builtin_strcpy",
BT_FN_STRING_STRING_CONST_STRING, BT_FN_STRING_STRING_CONST_STRING,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRNCPY, DEF_LIB_BUILTIN(BUILT_IN_STRNCPY,
"__builtin_strncpy", "__builtin_strncpy",
BT_FN_STRING_STRING_CONST_STRING_SIZE, BT_FN_STRING_STRING_CONST_STRING_SIZE,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRCMP, DEF_LIB_BUILTIN(BUILT_IN_STRCMP,
"__builtin_strcmp", "__builtin_strcmp",
BT_FN_INT_CONST_STRING_CONST_STRING, BT_FN_INT_CONST_STRING_CONST_STRING,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRNCMP, DEF_LIB_BUILTIN(BUILT_IN_STRNCMP,
"__builtin_strncmp", "__builtin_strncmp",
BT_FN_INT_CONST_STRING_CONST_STRING_SIZE, BT_FN_INT_CONST_STRING_CONST_STRING_SIZE,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRLEN, DEF_LIB_BUILTIN(BUILT_IN_STRLEN,
"__builtin_strlen", "__builtin_strlen",
BT_FN_SIZE_CONST_STRING, BT_FN_SIZE_CONST_STRING,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_STRSTR, DEF_LIB_BUILTIN(BUILT_IN_STRSTR,
"__builtin_strstr", "__builtin_strstr",
BT_FN_STRING_CONST_STRING_CONST_STRING, BT_FN_STRING_CONST_STRING_CONST_STRING,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRPBRK, DEF_LIB_BUILTIN(BUILT_IN_STRPBRK,
"__builtin_strpbrk", "__builtin_strpbrk",
BT_FN_STRING_CONST_STRING_CONST_STRING, BT_FN_STRING_CONST_STRING_CONST_STRING,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRSPN, DEF_LIB_BUILTIN(BUILT_IN_STRSPN,
"__builtin_strspn", "__builtin_strspn",
BT_FN_SIZE_CONST_STRING_CONST_STRING, BT_FN_SIZE_CONST_STRING_CONST_STRING,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRCSPN, DEF_LIB_BUILTIN(BUILT_IN_STRCSPN,
"__builtin_strcspn", "__builtin_strcspn",
BT_FN_SIZE_CONST_STRING_CONST_STRING, BT_FN_SIZE_CONST_STRING_CONST_STRING,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1_2)
DEF_LIB_BUILTIN(BUILT_IN_STRCHR, DEF_LIB_BUILTIN(BUILT_IN_STRCHR,
"__builtin_strchr", "__builtin_strchr",
BT_FN_STRING_CONST_STRING_INT, BT_FN_STRING_CONST_STRING_INT,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_STRRCHR, DEF_LIB_BUILTIN(BUILT_IN_STRRCHR,
"__builtin_strrchr", "__builtin_strrchr",
BT_FN_STRING_CONST_STRING_INT, BT_FN_STRING_CONST_STRING_INT,
ATTR_PURE_NOTHROW_LIST) ATTR_PURE_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_SQRT, DEF_LIB_BUILTIN(BUILT_IN_SQRT,
"__builtin_sqrt", "__builtin_sqrt",
...@@ -647,28 +650,28 @@ DEF_GCC_BUILTIN(BUILT_IN_HUGE_VALL, ...@@ -647,28 +650,28 @@ DEF_GCC_BUILTIN(BUILT_IN_HUGE_VALL,
DEF_LIB_BUILTIN(BUILT_IN_NAN, DEF_LIB_BUILTIN(BUILT_IN_NAN,
"__builtin_nan", "__builtin_nan",
BT_FN_DOUBLE_CONST_STRING, BT_FN_DOUBLE_CONST_STRING,
ATTR_CONST_NOTHROW_LIST) ATTR_CONST_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_NANF, DEF_LIB_BUILTIN(BUILT_IN_NANF,
"__builtin_nanf", "__builtin_nanf",
BT_FN_FLOAT_CONST_STRING, BT_FN_FLOAT_CONST_STRING,
ATTR_CONST_NOTHROW_LIST) ATTR_CONST_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_NANL, DEF_LIB_BUILTIN(BUILT_IN_NANL,
"__builtin_nanl", "__builtin_nanl",
BT_FN_LONG_DOUBLE_CONST_STRING, BT_FN_LONG_DOUBLE_CONST_STRING,
ATTR_CONST_NOTHROW_LIST) ATTR_CONST_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_NANS, DEF_LIB_BUILTIN(BUILT_IN_NANS,
"__builtin_nans", "__builtin_nans",
BT_FN_DOUBLE_CONST_STRING, BT_FN_DOUBLE_CONST_STRING,
ATTR_CONST_NOTHROW_LIST) ATTR_CONST_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_NANSF, DEF_LIB_BUILTIN(BUILT_IN_NANSF,
"__builtin_nansf", "__builtin_nansf",
BT_FN_FLOAT_CONST_STRING, BT_FN_FLOAT_CONST_STRING,
ATTR_CONST_NOTHROW_LIST) ATTR_CONST_NOTHROW_NONNULL_1)
DEF_LIB_BUILTIN(BUILT_IN_NANSL, DEF_LIB_BUILTIN(BUILT_IN_NANSL,
"__builtin_nansl", "__builtin_nansl",
BT_FN_LONG_DOUBLE_CONST_STRING, BT_FN_LONG_DOUBLE_CONST_STRING,
ATTR_CONST_NOTHROW_LIST) ATTR_CONST_NOTHROW_NONNULL_1)
DEF_GCC_BUILTIN(BUILT_IN_SAVEREGS, DEF_GCC_BUILTIN(BUILT_IN_SAVEREGS,
"__builtin_saveregs", "__builtin_saveregs",
...@@ -744,7 +747,7 @@ DEF_LIB_BUILTIN(BUILT_IN_PUTCHAR, ...@@ -744,7 +747,7 @@ DEF_LIB_BUILTIN(BUILT_IN_PUTCHAR,
DEF_LIB_BUILTIN(BUILT_IN_PUTS, DEF_LIB_BUILTIN(BUILT_IN_PUTS,
"__builtin_puts", "__builtin_puts",
BT_FN_INT_CONST_STRING, BT_FN_INT_CONST_STRING,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1)
DEF_C99_BUILTIN(BUILT_IN_SNPRINTF, DEF_C99_BUILTIN(BUILT_IN_SNPRINTF,
"__builtin_snprintf", "__builtin_snprintf",
BT_FN_INT_STRING_SIZE_CONST_STRING_VAR, BT_FN_INT_STRING_SIZE_CONST_STRING_VAR,
...@@ -793,17 +796,17 @@ DEF_LIB_BUILTIN(BUILT_IN_VSPRINTF, ...@@ -793,17 +796,17 @@ DEF_LIB_BUILTIN(BUILT_IN_VSPRINTF,
DEF_FALLBACK_BUILTIN(BUILT_IN_FPUTC, DEF_FALLBACK_BUILTIN(BUILT_IN_FPUTC,
"__builtin_fputc", "__builtin_fputc",
BT_FN_INT_INT_PTR, BT_FN_INT_INT_PTR,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_2)
DEF_BUILTIN (BUILT_IN_FPUTS, DEF_BUILTIN (BUILT_IN_FPUTS,
"__builtin_fputs", "__builtin_fputs",
BUILT_IN_NORMAL, BUILT_IN_NORMAL,
BT_FN_INT_CONST_STRING_PTR, BT_FN_INT_CONST_STRING_PTR,
BT_FN_INT_VAR, BT_FN_INT_VAR,
true, true, false, ATTR_NOTHROW_LIST, true) true, true, false, ATTR_NOTHROW_NONNULL_1_2, true)
DEF_FALLBACK_BUILTIN(BUILT_IN_FWRITE, DEF_FALLBACK_BUILTIN(BUILT_IN_FWRITE,
"__builtin_fwrite", "__builtin_fwrite",
BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR, BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR,
ATTR_NOTHROW_LIST) ATTR_NOTHROW_NONNULL_1_4)
DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF, DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF,
"__builtin_fprintf", "__builtin_fprintf",
BT_FN_INT_PTR_CONST_STRING_VAR, BT_FN_INT_PTR_CONST_STRING_VAR,
...@@ -813,10 +816,10 @@ DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF, ...@@ -813,10 +816,10 @@ DEF_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF,
DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR_UNLOCKED, DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTCHAR_UNLOCKED,
"__builtin_putchar_unlocked", "__builtin_putchar_unlocked",
BT_FN_INT_INT) BT_FN_INT_INT, ATTR_NOTHROW_LIST)
DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTS_UNLOCKED, DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_PUTS_UNLOCKED,
"__builtin_puts_unlocked", "__builtin_puts_unlocked",
BT_FN_INT_CONST_STRING) BT_FN_INT_CONST_STRING, ATTR_NOTHROW_NONNULL_1)
DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF_UNLOCKED, 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,
...@@ -831,16 +834,16 @@ DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF_UNLOCKED, ...@@ -831,16 +834,16 @@ DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_PRINTF_UNLOCKED,
DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FPUTC_UNLOCKED, DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FPUTC_UNLOCKED,
"__builtin_fputc_unlocked", "__builtin_fputc_unlocked",
BT_FN_INT_INT_PTR) BT_FN_INT_INT_PTR, ATTR_NOTHROW_NONNULL_2)
DEF_BUILTIN (BUILT_IN_FPUTS_UNLOCKED, DEF_BUILTIN (BUILT_IN_FPUTS_UNLOCKED,
"__builtin_fputs_unlocked", "__builtin_fputs_unlocked",
BUILT_IN_NORMAL, BUILT_IN_NORMAL,
BT_FN_INT_CONST_STRING_PTR, BT_FN_INT_CONST_STRING_PTR,
BT_FN_INT_VAR, BT_FN_INT_VAR,
true, true, true, ATTR_NOTHROW_LIST, true) true, true, true, ATTR_NOTHROW_NONNULL_1_2, true)
DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FWRITE_UNLOCKED, DEF_EXT_FALLBACK_BUILTIN(BUILT_IN_FWRITE_UNLOCKED,
"__builtin_fwrite_unlocked", "__builtin_fwrite_unlocked",
BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR) BT_FN_SIZE_CONST_PTR_SIZE_SIZE_PTR, ATTR_NOTHROW_NONNULL_1_4)
DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF_UNLOCKED, DEF_EXT_FRONT_END_LIB_BUILTIN(BUILT_IN_FPRINTF_UNLOCKED,
"__builtin_fprintf_unlocked", "__builtin_fprintf_unlocked",
BT_FN_INT_PTR_CONST_STRING_VAR, BT_FN_INT_PTR_CONST_STRING_VAR,
...@@ -961,5 +964,5 @@ DEF_LIB_BUILTIN(BUILT_IN_CALLOC, ...@@ -961,5 +964,5 @@ DEF_LIB_BUILTIN(BUILT_IN_CALLOC,
DEF_EXT_LIB_BUILTIN(BUILT_IN_STRDUP, DEF_EXT_LIB_BUILTIN(BUILT_IN_STRDUP,
"__builtin_strdup", "__builtin_strdup",
BT_FN_STRING_CONST_STRING, BT_FN_STRING_CONST_STRING,
ATTR_MALLOC_NOTHROW_LIST) ATTR_MALLOC_NOTHROW_NONNULL_1)
2003-05-04 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/nonnull-3.c: New test.
2003-05-04 Neil Booth <neil@daikokuya.co.uk> 2003-05-04 Neil Booth <neil@daikokuya.co.uk>
* gcc.dg/cpp/Wtrigraphs.c: Update. * gcc.dg/cpp/Wtrigraphs.c: Update.
......
/* Test for the "nonnull" function attribute on builtins. Use the
"__builtin_" style below so we don't need prototypes. */
/* Origin: Kaveh R. Ghazi <ghazi@caip.rutgers.edu> */
/* { dg-do compile } */
/* { dg-options "-Wnonnull" } */
#include <stddef.h>
void
foo (void *p, char *s)
{
__builtin_bzero (NULL, 0);
__builtin_bcopy (NULL, p, 0);
__builtin_bcopy (p, NULL, 0);
__builtin_bcmp (NULL, p, 0);
__builtin_bcmp (p, NULL, 0);
__builtin_index (NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_rindex (NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_memcpy (p, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_memcpy (NULL, p, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_memmove (p, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_memmove (NULL, p, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_memcmp (p, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_memcmp (NULL, p, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_memset (NULL, 0, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_mempcpy (p, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_mempcpy (NULL, p, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strcat (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_strcat (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strncat (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strncat (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_stpcpy (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_stpcpy (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strcpy (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_strcpy (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strncpy (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strncpy (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strcmp (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_strcmp (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strncmp (NULL, s, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strncmp (s, NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strlen (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strstr (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_strstr (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strpbrk (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_strpbrk (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strspn (NULL, s); /* { dg-warning "null" "null pointer check" } */
__builtin_strspn (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_strchr (NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strrchr (NULL, 16); /* { dg-warning "null" "null pointer check" } */
__builtin_strdup (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_nan (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_nanf (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_nanl (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_nans (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_nansf (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_nansl (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_puts (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_fputc (*s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_fputs (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_fputs (NULL, p); /* { dg-warning "null" "null pointer check" } */
__builtin_fwrite (s, 16, 16, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_fwrite (NULL, 16, 16, p); /* { dg-warning "null" "null pointer check" } */
__builtin_puts_unlocked (NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_fputc_unlocked (*s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_fputs_unlocked (s, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_fputs_unlocked (NULL, p); /* { dg-warning "null" "null pointer check" } */
__builtin_fwrite_unlocked (s, 16, 16, NULL); /* { dg-warning "null" "null pointer check" } */
__builtin_fwrite_unlocked (NULL, 16, 16, p); /* { dg-warning "null" "null pointer check" } */
}
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