gcc/ChangeLog: PR c/66970 * doc/cpp.texi (__has_builtin): Document. * doc/extend.texi (__builtin_frob_return_addr): Correct spelling. gcc/c/ChangeLog: PR c/66970 * c-decl.c (names_builtin_p): Define a new function. gcc/c-family/ChangeLog: PR c/66970 * c-common.c (c_common_nodes_and_builtins): Call c_define_builtins even when only preprocessing. * c-common.h (names_builtin_p): Declare new function. * c-lex.c (init_c_lex): Set has_builtin. (c_common_has_builtin): Define a new function. * c-ppoutput.c (init_pp_output): Set has_builtin. gcc/cp/ChangeLog: PR c/66970 * cp-objcp-common.c (names_builtin_p): Define new function. gcc/testsuite/ChangeLog: PR c/66970 * c-c++-common/cpp/has-builtin-2.c: New test. * c-c++-common/cpp/has-builtin-3.c: New test. * c-c++-common/cpp/has-builtin.c: New test. From-SVN: r277544
37 lines
968 B
C
37 lines
968 B
C
/* PR c/66970 - Add __has_builtin() macro
|
|
Verify __has_builtin evaluation for disabled library built-ins.
|
|
{ dg-do compile }
|
|
{ dg-options "-fno-builtin-abs" }
|
|
{ dg-additional-options "-std=c90" { target c } } */
|
|
|
|
#if !__has_builtin (__builtin_abs)
|
|
// __builtin_xxx is always available regardless of -fno-builtin.
|
|
# error "__has_builtin (__builtin_abs) failed"
|
|
#endif
|
|
|
|
#if __has_builtin (abs)
|
|
# error "__has_builtin (abs) failed"
|
|
#endif
|
|
|
|
#if __has_builtin (abs)
|
|
# error "__has_builtin (abs) failed"
|
|
#endif
|
|
|
|
|
|
#if !__has_builtin (__builtin_vsnprintf)
|
|
// __builtin_vsnprintf is available in all language modes.
|
|
# error "__has_builtin (__builtin_vsnprintf) failed"
|
|
#endif
|
|
|
|
#if !__has_builtin (vsnprintf)
|
|
# if __cplusplus
|
|
// vsnprintf is always available in C++.
|
|
# error "__has_builtin (vsnprintf) failed"
|
|
# endif
|
|
#else
|
|
# if !__cplusplus
|
|
// vsnprintf is a C99 function not available in C90.
|
|
# error "__has_builtin (vsnprintf) failed"
|
|
# endif
|
|
#endif
|