From ad1539d5555a161cf6851de8995641d6dfe792d9 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 28 Oct 2019 22:46:28 +0000 Subject: PR c/66970 - Add __has_builtin() macro 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 --- libcpp/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libcpp/init.c') diff --git a/libcpp/init.c b/libcpp/init.c index 4bcec7b..b094317 100644 --- a/libcpp/init.c +++ b/libcpp/init.c @@ -403,6 +403,7 @@ static const struct builtin_macro builtin_array[] = B("__COUNTER__", BT_COUNTER, true), B("__has_attribute", BT_HAS_ATTRIBUTE, true), B("__has_cpp_attribute", BT_HAS_ATTRIBUTE, true), + B("__has_builtin", BT_HAS_BUILTIN, true), /* Keep builtins not used for -traditional-cpp at the end, and update init_builtins() if any more are added. */ B("_Pragma", BT_PRAGMA, true), @@ -483,7 +484,8 @@ cpp_init_special_builtins (cpp_reader *pfile) for (b = builtin_array; b < builtin_array + n; b++) { - if (b->value == BT_HAS_ATTRIBUTE + if ((b->value == BT_HAS_ATTRIBUTE + || b->value == BT_HAS_BUILTIN) && (CPP_OPTION (pfile, lang) == CLK_ASM || pfile->cb.has_attribute == NULL)) continue; -- cgit v1.1