From patchwork Fri Oct 23 12:48:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1386736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=DxgSJIcO; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CHkYB0827z9sV0 for ; Fri, 23 Oct 2020 23:48:12 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 70BD43987C1D; Fri, 23 Oct 2020 12:48:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 4FF563857024 for ; Fri, 23 Oct 2020 12:48:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4FF563857024 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qt1-x82a.google.com with SMTP id p88so742535qtd.12 for ; Fri, 23 Oct 2020 05:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=KcmgngQlGxSrjDlr9iSgUNYT/w4MNJW60oCGrgFY4Lo=; b=DxgSJIcOa4vZPi+ULB4wzXMw14mv2C/NaCBHfUbjIRNCa7i6le/RNWjrvHpReLApo+ Qcoqm2DgLNeCqf2NHqVR/7epMKQ3PfwqB3q7ruuTJZnca+Krk4Bka32YV2zaH6RS6ICJ pLkSl7AyLNDseaQShwiOw4iwU/AxfFIKJETyUGYI6FspEBXM8PTMZlSIly3YIkfpC430 2MjStae2i/9gPfsoHrx7gVaCxEM6wRhn0Fpq6SwgpYNDjnXKlMXPNLpkbK80HkTWzuHu Zcn9HZJ1HoJk70m6Xis9yQyVz1D4f1rqKt6HUNIF1RBvoOtJD3GoP+lItA/7miMe4haw /xNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=KcmgngQlGxSrjDlr9iSgUNYT/w4MNJW60oCGrgFY4Lo=; b=WUOTLyPIpjxGaBlR9ni4NCaQp1wAz0snsILTx5xCRNTVbGEBDklnwwlOAkqcdHZG1U VBpSF1aF/nE60NmLN1gnOLpS02dcfS4zwaVIofglz1ZRSUoX0VjjRSDh0/yOXjxx+Tkr C43XLD44W/OpXqyhS4/yuVRcm0JKcqN0YuRJRXQGsvRBGWGtC5NfLjaa6hrcmMNxyF6w f1IQBnPU3h1QS4tzUYwmYGmCoApnXRosFlUQgXpSk51NX5S4pSqxjJMY4IboPzfHe9vV REoOmNzXWPC9QmP/Ok8BeaGPsCxAOOFNfH/zyO6y9fnISOtnAwv90/Y5+UwNIiYCvppK 0BVw== X-Gm-Message-State: AOAM532BPPaQrE3lHNMnje1kTln/dgS7oxcvzy940RPdbhJnQjk2ovBo AICcFtgHLvqyJ17LE8m3RcM= X-Google-Smtp-Source: ABdhPJy5lDDUq4JmDqHI23WQQdht9UcoQMNv2MJyxG4C+SOYUiLaU5Utw543ANQO2SUOtSxOIck1JA== X-Received: by 2002:ac8:5793:: with SMTP id v19mr1763421qta.83.1603457285549; Fri, 23 Oct 2020 05:48:05 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:1102:8153:547a:5e1b:a29b? ([2620:10d:c091:480::1:7959]) by smtp.googlemail.com with ESMTPSA id o47sm771383qtk.21.2020.10.23.05.48.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Oct 2020 05:48:04 -0700 (PDT) To: GCC Patches , Richard Biener , Joseph Myers , Jan Hubicka , Ian Lance Taylor From: Nathan Sidwell Subject: Rename DECL_IS_BUILTIN to DECL_IS_UNDECLARED_BUILTIN Message-ID: <18e5449c-861b-dae2-5417-a102966c7491@acm.org> Date: Fri, 23 Oct 2020 08:48:03 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Patch affects C++, C, GO, common-core In cleaning up C++'s handling of hidden decls, I renamed its DECL_BUILTIN_P, which checks for loc == BUILTINS_LOCATION to DECL_UNDECLARED_BUILTIN_P, because the location gets updated, if user source declares the builtin, and the predicate no longer holds. The original name was confusing me. (The builtin may still retain builtin properties in the redeclaration, and other predicates can still detect that.) I discovered that tree.h had its own variant 'DECL_IS_BUILTIN', which behaves in (almost) the same manner. And therefore has the same mutating behaviour. This patch deletes the C++ one, and renames tree.h's to DECL_IS_UNDECLARED_BUILTIN, to emphasize its non-constantness. I guess _IS_ wins over _P :) The indirection via SOURCE_LOCUS was introduced by Richard in 2012: 2012-09-26 Richard Guenther * tree.h (DECL_IS_BUILTIN): Compare LOCATION_LOCUS. From-SVN: r191759 I couldn't find the email on gcc-patches, but I don't see why this is necessary -- no undeclared builtin has an adhoc location, they're all BUILTINS_LOCATION, or UNKNOWN_LOCATION. That some builtins have UNKNOWN_LOCATION is why the test is <= rather than ==. This seems wrong, and we should be using BUILTINS_LOCATION everywhere. But that's a different bug. bootstrapped on x86-64-linux and test results look the same across all the languages I can build. ok? gcc/ * tree.h (DECL_IS_BUILTIN): Rename to ... (DECL_IS_UNDECLARED_BUILTIN): ... here. No need to use SOURCE_LOCUS. * calls.c (maybe_warn_alloc_args_overflow): Adjust for rename. * cfgexpand.c (pass_expand::execute): Likewise. * dwarf2out.c (base_type_die, is_naming_typedef_decl): Likewise. * godump.c (go_decl, go_type_decl): Likewise. * print-tree.c (print_decl_identifier): Likewise. * tree-pretty-print.c (dump_generic_node): Likewise. * tree-ssa-ccp.c (pass_post_ipa_warn::execute): Likewise. * xcoffout.c (xcoff_assign_fundamental_type_number): Likewise. gcc/c-family/ * c-ada-spec.c (collect_ada_nodes): Rename DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN. (collect_ada_node): Likewise. (dump_forward_type): Likewise. * c-common.c (set_underlying_type): Rename DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN. (user_facing_original_type): Likewise. (c_common_finalize_early_debug): Likewise. gcc/c/ * c-decl.c (diagnose_mismatched_decls): Rename DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN. (warn_if_shadowing, implicitly_declare, names_builtin_p) (collect_source_refs): Likewise. * c-typeck.c (inform_declaration, inform_for_arg) (convert_for_assignment): Likewise. gcc/cp/ * cp-tree.h (DECL_UNDECLARED_BUILTIN_P): Delete. * cp-objcp-common.c (names_bultin_p): Rename DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN. * decl.c (decls_match): Likewise. Replace DECL_UNDECLARED_BUILTIN_P with DECL_IS_UNDECLARED_BUILTIN. (duplicate_decls): Likewise. * decl2.c (collect_source_refs): Likewise. * name-lookup.c (anticipated_builtin_p, print_binding_level) (do_nonmember_using_decl): Likewise. * pt.c (builtin_pack_fn_p): Likewise. * typeck.c (error_args_num): Likewise. gcc/lto/ * lto-symtab.c (lto_symtab_merge_decls_1): Rename DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN. gcc/go/ * go-gcc.cc (Gcc_backend::call_expression): Rename DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN. libcc1/ * libcc1plugin.cc (address_rewriter): Rename DECL_IS_BUILTIN->DECL_IS_UNDECLARED_BUILTIN. * libcp1plugin.cc (supplement_binding): Likewise. nathan diff --git i/gcc/c-family/c-ada-spec.c w/gcc/c-family/c-ada-spec.c index c75b173eec3..266a7fe0fa4 100644 --- i/gcc/c-family/c-ada-spec.c +++ w/gcc/c-family/c-ada-spec.c @@ -713,7 +713,7 @@ collect_ada_nodes (tree t, const char *source_file) in the context of bindings) and namespaces (we do not handle them properly yet). */ for (n = t; n; n = TREE_CHAIN (n)) - if (!DECL_IS_BUILTIN (n) + if (!DECL_IS_UNDECLARED_BUILTIN (n) && TREE_CODE (n) != NAMESPACE_DECL && LOCATION_FILE (decl_sloc (n, false)) == source_file) to_dump_count++; @@ -723,7 +723,7 @@ collect_ada_nodes (tree t, const char *source_file) /* Store the relevant nodes. */ for (n = t; n; n = TREE_CHAIN (n)) - if (!DECL_IS_BUILTIN (n) + if (!DECL_IS_UNDECLARED_BUILTIN (n) && TREE_CODE (n) != NAMESPACE_DECL && LOCATION_FILE (decl_sloc (n, false)) == source_file) to_dump[i++] = n; @@ -2321,7 +2321,7 @@ dump_ada_node (pretty_printer *buffer, tree node, tree type, int spc, return 0; case TYPE_DECL: - if (DECL_IS_BUILTIN (node)) + if (DECL_IS_UNDECLARED_BUILTIN (node)) { /* Don't print the declaration of built-in types. */ if (name_only) @@ -2444,7 +2444,7 @@ dump_forward_type (pretty_printer *buffer, tree type, tree t, int spc) return; } - if (DECL_IS_BUILTIN (decl) || TREE_VISITED (decl)) + if (DECL_IS_UNDECLARED_BUILTIN (decl) || TREE_VISITED (decl)) return; /* Forward declarations are only needed within a given file. */ diff --git i/gcc/c-family/c-common.c w/gcc/c-family/c-common.c index e16ca3894bc..10c97d707f1 100644 --- i/gcc/c-family/c-common.c +++ w/gcc/c-family/c-common.c @@ -7836,7 +7836,7 @@ set_underlying_type (tree x) { if (x == error_mark_node) return; - if (DECL_IS_BUILTIN (x) && TREE_CODE (TREE_TYPE (x)) != ARRAY_TYPE) + if (DECL_IS_UNDECLARED_BUILTIN (x) && TREE_CODE (TREE_TYPE (x)) != ARRAY_TYPE) { if (TYPE_NAME (TREE_TYPE (x)) == 0) TYPE_NAME (TREE_TYPE (x)) = x; @@ -7870,7 +7870,7 @@ user_facing_original_type_p (const_tree type) tree decl = TYPE_NAME (type); /* Look through any typedef in "user" code. */ - if (!DECL_IN_SYSTEM_HEADER (decl) && !DECL_IS_BUILTIN (decl)) + if (!DECL_IN_SYSTEM_HEADER (decl) && !DECL_IS_UNDECLARED_BUILTIN (decl)) return true; /* If the original type is also named and is in the user namespace, @@ -8365,13 +8365,13 @@ reject_gcc_builtin (const_tree expr, location_t loc /* = UNKNOWN_LOCATION */) if (TREE_TYPE (expr) && TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE && TREE_CODE (expr) == FUNCTION_DECL - /* The intersection of DECL_BUILT_IN and DECL_IS_BUILTIN avoids + /* The intersection of DECL_BUILT_IN and DECL_IS_UNDECLARED_BUILTIN avoids false positives for user-declared built-ins such as abs or strlen, and for C++ operators new and delete. The c_decl_implicit() test avoids false positives for implicitly declared built-ins with library fallbacks (such as abs). */ && fndecl_built_in_p (expr) - && DECL_IS_BUILTIN (expr) + && DECL_IS_UNDECLARED_BUILTIN (expr) && !c_decl_implicit (expr) && !DECL_ASSEMBLER_NAME_SET_P (expr)) { @@ -9133,7 +9133,8 @@ c_common_finalize_early_debug (void) struct cgraph_node *cnode; FOR_EACH_FUNCTION (cnode) if (!cnode->alias && !cnode->thunk.thunk_p - && (cnode->has_gimple_body_p () || !DECL_IS_BUILTIN (cnode->decl))) + && (cnode->has_gimple_body_p () + || !DECL_IS_UNDECLARED_BUILTIN (cnode->decl))) (*debug_hooks->early_global_decl) (cnode->decl); } diff --git i/gcc/c/c-decl.c w/gcc/c/c-decl.c index 81b9adb6a33..bab0051de08 100644 --- i/gcc/c/c-decl.c +++ w/gcc/c/c-decl.c @@ -2051,7 +2051,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, } } else if (TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_IS_BUILTIN (olddecl)) + && DECL_IS_UNDECLARED_BUILTIN (olddecl)) { /* A conflicting function declaration for a predeclared function that isn't actually built in. Objective C uses @@ -2265,7 +2265,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, built in, newdecl silently overrides olddecl. The latter occur only in Objective C; see also above. (FIXME: Make Objective C use normal builtins.) */ - if (!DECL_IS_BUILTIN (olddecl) + if (!DECL_IS_UNDECLARED_BUILTIN (olddecl) && !DECL_EXTERN_INLINE (olddecl)) { auto_diagnostic_group d; @@ -2978,7 +2978,7 @@ warn_if_shadowing (tree new_decl) || warn_shadow_local || warn_shadow_compatible_local) /* No shadow warnings for internally generated vars. */ - || DECL_IS_BUILTIN (new_decl)) + || DECL_IS_UNDECLARED_BUILTIN (new_decl)) return; /* Is anything being shadowed? Invisible decls do not count. */ @@ -3631,7 +3631,7 @@ implicitly_declare (location_t loc, tree functionid) in the external scope because they're pushed before the file scope gets created. Catch this here and rebind them into the file scope. */ - if (!fndecl_built_in_p (decl) && DECL_IS_BUILTIN (decl)) + if (!fndecl_built_in_p (decl) && DECL_IS_UNDECLARED_BUILTIN (decl)) { bind (functionid, decl, file_scope, /*invisible=*/false, /*nested=*/true, @@ -10469,7 +10469,7 @@ names_builtin_p (const char *name) { tree id = get_identifier (name); if (tree decl = identifier_global_value (id)) - return TREE_CODE (decl) == FUNCTION_DECL && DECL_IS_BUILTIN (decl); + return TREE_CODE (decl) == FUNCTION_DECL && DECL_IS_UNDECLARED_BUILTIN (decl); /* Also detect common reserved C words that aren't strictly built-in functions. */ @@ -12103,12 +12103,12 @@ collect_source_refs (void) { decls = DECL_INITIAL (t); for (decl = BLOCK_VARS (decls); decl; decl = TREE_CHAIN (decl)) - if (!DECL_IS_BUILTIN (decl)) + if (!DECL_IS_UNDECLARED_BUILTIN (decl)) collect_source_ref (DECL_SOURCE_FILE (decl)); } for (decl = BLOCK_VARS (ext_block); decl; decl = TREE_CHAIN (decl)) - if (!DECL_IS_BUILTIN (decl)) + if (!DECL_IS_UNDECLARED_BUILTIN (decl)) collect_source_ref (DECL_SOURCE_FILE (decl)); } diff --git i/gcc/c/c-typeck.c w/gcc/c/c-typeck.c index dd3e30958ac..a4a3b16dfa0 100644 --- i/gcc/c/c-typeck.c +++ w/gcc/c/c-typeck.c @@ -3014,7 +3014,8 @@ build_function_call (location_t loc, tree function, tree params) static void inform_declaration (tree decl) { - if (decl && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_IS_BUILTIN (decl))) + if (decl && (TREE_CODE (decl) != FUNCTION_DECL + || !DECL_IS_UNDECLARED_BUILTIN (decl))) inform (DECL_SOURCE_LOCATION (decl), "declared here"); } @@ -6500,7 +6501,7 @@ inform_for_arg (tree fundecl, location_t ploc, int parmnum, tree expected_type, tree actual_type) { location_t loc; - if (fundecl && !DECL_IS_BUILTIN (fundecl)) + if (fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl)) loc = get_fndecl_argument_location (fundecl, parmnum - 1); else loc = ploc; @@ -6750,7 +6751,7 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, if (pedwarn (expr_loc, OPT_Wc___compat, "enum conversion when " "passing argument %d of %qE is invalid in C++", parmnum, rname)) - inform ((fundecl && !DECL_IS_BUILTIN (fundecl)) + inform ((fundecl && !DECL_IS_UNDECLARED_BUILTIN (fundecl)) ? DECL_SOURCE_LOCATION (fundecl) : expr_loc, "expected %qT but argument is of type %qT", type, rhstype); @@ -7161,7 +7162,8 @@ convert_for_assignment (location_t location, location_t expr_loc, tree type, case ic_argpass: /* Do not warn for built-in functions, for example memcpy, since we control how they behave and they can be useful in this area. */ - if (TREE_CODE (rname) != FUNCTION_DECL || !DECL_IS_BUILTIN (rname)) + if (TREE_CODE (rname) != FUNCTION_DECL + || !DECL_IS_UNDECLARED_BUILTIN (rname)) warning_at (location, OPT_Wscalar_storage_order, "passing argument %d of %qE from incompatible " "scalar storage order", parmnum, rname); diff --git i/gcc/calls.c w/gcc/calls.c index a12b84744c0..4b7f5b35293 100644 --- i/gcc/calls.c +++ w/gcc/calls.c @@ -1539,7 +1539,7 @@ maybe_warn_alloc_args_overflow (tree fn, tree exp, tree args[2], int idx[2]) { location_t fnloc = DECL_SOURCE_LOCATION (fn); - if (DECL_IS_BUILTIN (fn)) + if (DECL_IS_UNDECLARED_BUILTIN (fn)) inform (loc, "in a call to built-in allocation function %qD", fn); else diff --git i/gcc/cfgexpand.c w/gcc/cfgexpand.c index 1eaa1da11b9..fc552cce58f 100644 --- i/gcc/cfgexpand.c +++ w/gcc/cfgexpand.c @@ -6406,7 +6406,7 @@ pass_expand::execute (function *fun) rtl_profile_for_bb (ENTRY_BLOCK_PTR_FOR_FN (fun)); insn_locations_init (); - if (!DECL_IS_BUILTIN (current_function_decl)) + if (!DECL_IS_UNDECLARED_BUILTIN (current_function_decl)) { /* Eventually, all FEs should explicitly set function_start_locus. */ if (LOCATION_LOCUS (fun->function_start_locus) == UNKNOWN_LOCATION) diff --git i/gcc/cp/cp-objcp-common.c w/gcc/cp/cp-objcp-common.c index e1397b7b710..a38bb0a0661 100644 --- i/gcc/cp/cp-objcp-common.c +++ w/gcc/cp/cp-objcp-common.c @@ -366,7 +366,8 @@ names_builtin_p (const char *name) tree id = get_identifier (name); if (tree binding = get_global_binding (id)) { - if (TREE_CODE (binding) == FUNCTION_DECL && DECL_IS_BUILTIN (binding)) + if (TREE_CODE (binding) == FUNCTION_DECL + && DECL_IS_UNDECLARED_BUILTIN (binding)) return true; /* Handle the case when an overload for a built-in name exists. */ @@ -376,7 +377,7 @@ names_builtin_p (const char *name) for (ovl_iterator it (binding); it; ++it) { tree decl = *it; - if (DECL_IS_BUILTIN (decl)) + if (DECL_IS_UNDECLARED_BUILTIN (decl)) return true; } } diff --git i/gcc/cp/cp-tree.h w/gcc/cp/cp-tree.h index 5c06ac3789e..d4207032d00 100644 --- i/gcc/cp/cp-tree.h +++ w/gcc/cp/cp-tree.h @@ -4045,11 +4045,6 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) #define FNDECL_USED_AUTO(NODE) \ TREE_LANG_FLAG_2 (FUNCTION_DECL_CHECK (NODE)) -/* True if NODE is an undeclared builtin decl. As soon as the user - declares it, the location will be updated. */ -#define DECL_UNDECLARED_BUILTIN_P(NODE) \ - (DECL_SOURCE_LOCATION(NODE) == BUILTINS_LOCATION) - /* True for artificial decls added for OpenMP privatized non-static data members. */ #define DECL_OMP_PRIVATIZED_MEMBER(NODE) \ diff --git i/gcc/cp/decl.c w/gcc/cp/decl.c index 5f370e60b4e..e53c90a5fbf 100644 --- i/gcc/cp/decl.c +++ w/gcc/cp/decl.c @@ -1002,7 +1002,7 @@ decls_match (tree newdecl, tree olddecl, bool record_versions /* = true */) /* A new declaration doesn't match a built-in one unless it is also extern "C". */ - if (DECL_IS_BUILTIN (olddecl) + if (DECL_IS_UNDECLARED_BUILTIN (olddecl) && DECL_EXTERN_C_P (olddecl) && !DECL_EXTERN_C_P (newdecl)) return 0; @@ -1205,7 +1205,7 @@ check_redeclaration_exception_specification (tree new_decl, all declarations, including the definition and an explicit specialization, of that function shall have an exception-specification with the same set of type-ids. */ - if (! DECL_IS_BUILTIN (old_decl) + if (! DECL_IS_UNDECLARED_BUILTIN (old_decl) && !comp_except_specs (new_exceptions, old_exceptions, ce_normal)) { const char *const msg @@ -1465,7 +1465,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) /* Check for redeclaration and other discrepancies. */ if (TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_UNDECLARED_BUILTIN_P (olddecl)) + && DECL_IS_UNDECLARED_BUILTIN (olddecl)) { if (TREE_CODE (newdecl) != FUNCTION_DECL) { @@ -1517,7 +1517,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) /* A new declaration doesn't match a built-in one unless it is also extern "C". */ - gcc_assert (DECL_IS_BUILTIN (olddecl)); + gcc_assert (DECL_IS_UNDECLARED_BUILTIN (olddecl)); gcc_assert (DECL_EXTERN_C_P (olddecl)); if (!DECL_EXTERN_C_P (newdecl)) return NULL_TREE; @@ -1627,11 +1627,11 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) /* Replace the old RTL to avoid problems with inlining. */ COPY_DECL_RTL (newdecl, olddecl); } - /* Even if the types match, prefer the new declarations type for - built-ins which have not been explicitly declared, for - exception lists, etc... */ - else if (DECL_IS_BUILTIN (olddecl)) + else { + /* Even if the types match, prefer the new declarations type + for built-ins which have not been explicitly declared, + for exception lists, etc... */ tree type = TREE_TYPE (newdecl); tree attribs = (*targetm.merge_type_attributes) (TREE_TYPE (olddecl), type); @@ -1776,7 +1776,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool hiding, bool was_hidden) newdecl); inform (olddecl_loc, "previous declaration %q#D", olddecl); - return NULL_TREE; + return error_mark_node; } /* For function versions, params and types match, but they are not ambiguous. */ diff --git i/gcc/cp/decl2.c w/gcc/cp/decl2.c index 2f0d6370146..a1e81690e86 100644 --- i/gcc/cp/decl2.c +++ w/gcc/cp/decl2.c @@ -4363,7 +4363,7 @@ collect_source_refs (tree namespc) { /* Iterate over names in this name space. */ for (tree t = NAMESPACE_LEVEL (namespc)->names; t; t = TREE_CHAIN (t)) - if (DECL_IS_BUILTIN (t)) + if (DECL_IS_UNDECLARED_BUILTIN (t)) ; else if (TREE_CODE (t) == NAMESPACE_DECL && !DECL_NAMESPACE_ALIAS (t)) collect_source_refs (t); diff --git i/gcc/cp/name-lookup.c w/gcc/cp/name-lookup.c index 46374278068..7e31745dad0 100644 --- i/gcc/cp/name-lookup.c +++ w/gcc/cp/name-lookup.c @@ -2130,7 +2130,7 @@ anticipated_builtin_p (tree ovl) { return (TREE_CODE (ovl) == OVERLOAD && OVL_HIDDEN_P (ovl) - && DECL_UNDECLARED_BUILTIN_P (OVL_FUNCTION (ovl))); + && DECL_IS_UNDECLARED_BUILTIN (OVL_FUNCTION (ovl))); } /* BINDING records an existing declaration for a name in the current scope. @@ -3692,7 +3692,7 @@ print_binding_level (cp_binding_level* lvl) continue; if (no_print_builtins && (TREE_CODE (t) == TYPE_DECL) - && DECL_IS_BUILTIN (t)) + && DECL_IS_UNDECLARED_BUILTIN (t)) continue; /* Function decls tend to have longer names. */ @@ -4010,7 +4010,7 @@ do_nonmember_using_decl (name_lookup &lookup, bool fn_scope_p, } else if (old.using_p ()) continue; /* This is a using decl. */ - else if (old.hidden_p () && DECL_UNDECLARED_BUILTIN_P (old_fn)) + else if (old.hidden_p () && DECL_IS_UNDECLARED_BUILTIN (old_fn)) continue; /* This is an anticipated builtin. */ else if (!matching_fn_p (new_fn, old_fn)) continue; /* Parameters do not match. */ diff --git i/gcc/cp/pt.c w/gcc/cp/pt.c index dc664ec3798..b748cdf3e57 100644 --- i/gcc/cp/pt.c +++ w/gcc/cp/pt.c @@ -3767,7 +3767,7 @@ builtin_pack_fn_p (tree fn) { if (!fn || TREE_CODE (fn) != FUNCTION_DECL - || !DECL_IS_BUILTIN (fn)) + || !DECL_IS_UNDECLARED_BUILTIN (fn)) return false; if (id_equal (DECL_NAME (fn), "__integer_pack")) diff --git i/gcc/cp/typeck.c w/gcc/cp/typeck.c index 95b36a92491..c22fc6dbc44 100644 --- i/gcc/cp/typeck.c +++ w/gcc/cp/typeck.c @@ -4062,7 +4062,7 @@ error_args_num (location_t loc, tree fndecl, bool too_many_p) ? G_("too many arguments to function %q#D") : G_("too few arguments to function %q#D"), fndecl); - if (!DECL_IS_BUILTIN (fndecl)) + if (!DECL_IS_UNDECLARED_BUILTIN (fndecl)) inform (DECL_SOURCE_LOCATION (fndecl), "declared here"); } else diff --git i/gcc/dwarf2out.c w/gcc/dwarf2out.c index ba93a6c3d81..b00d43f5261 100644 --- i/gcc/dwarf2out.c +++ w/gcc/dwarf2out.c @@ -12854,7 +12854,7 @@ base_type_die (tree type, bool reverse) if ((dwarf_version >= 4 || !dwarf_strict) && TYPE_NAME (type) && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL - && DECL_IS_BUILTIN (TYPE_NAME (type)) + && DECL_IS_UNDECLARED_BUILTIN (TYPE_NAME (type)) && DECL_NAME (TYPE_NAME (type))) { const char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); @@ -26036,7 +26036,7 @@ is_naming_typedef_decl (const_tree decl) || TREE_CODE (decl) != TYPE_DECL || DECL_NAMELESS (decl) || !is_tagged_type (TREE_TYPE (decl)) - || DECL_IS_BUILTIN (decl) + || DECL_IS_UNDECLARED_BUILTIN (decl) || is_redundant_typedef (decl) /* It looks like Ada produces TYPE_DECLs that are very similar to C++ naming typedefs but that have different @@ -26948,7 +26948,7 @@ dwarf2out_decl (tree decl) /* Don't bother trying to generate any DIEs to represent any of the normal built-in types for the language we are compiling. */ - if (DECL_IS_BUILTIN (decl)) + if (DECL_IS_UNDECLARED_BUILTIN (decl)) return; /* If we are in terse mode, don't generate any DIEs for types. */ diff --git i/gcc/go/go-gcc.cc w/gcc/go/go-gcc.cc index 505fb1528fa..ba286fa8e82 100644 --- i/gcc/go/go-gcc.cc +++ w/gcc/go/go-gcc.cc @@ -2110,7 +2110,7 @@ Gcc_backend::call_expression(Bfunction*, // containing fcn for call if (optimize && TREE_CODE(fndecl) == FUNCTION_DECL && fndecl_built_in_p (fndecl, BUILT_IN_NORMAL) - && DECL_IS_BUILTIN (fndecl) + && DECL_IS_UNDECLARED_BUILTIN (fndecl) && nargs > 0 && ((SCALAR_FLOAT_TYPE_P(rettype) && SCALAR_FLOAT_TYPE_P(TREE_TYPE(args[0]))) diff --git i/gcc/godump.c w/gcc/godump.c index a7cd7edf7a4..29a45ce8979 100644 --- i/gcc/godump.c +++ w/gcc/godump.c @@ -484,7 +484,7 @@ static void go_decl (tree decl) { if (!TREE_PUBLIC (decl) - || DECL_IS_BUILTIN (decl) + || DECL_IS_UNDECLARED_BUILTIN (decl) || DECL_NAME (decl) == NULL_TREE) return; vec_safe_push (queue, decl); @@ -522,7 +522,7 @@ go_type_decl (tree decl, int local) { real_debug_hooks->type_decl (decl, local); - if (local || DECL_IS_BUILTIN (decl)) + if (local || DECL_IS_UNDECLARED_BUILTIN (decl)) return; if (DECL_NAME (decl) == NULL_TREE && (TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE diff --git i/gcc/lto/lto-symtab.c w/gcc/lto/lto-symtab.c index d5e38beb4b6..0058d98bdb9 100644 --- i/gcc/lto/lto-symtab.c +++ w/gcc/lto/lto-symtab.c @@ -694,8 +694,8 @@ lto_symtab_merge_decls_2 (symtab_node *first, bool diagnosed_p) location in that case. It also happens for AVR if two built-ins use the same asm name because their libgcc assembler code is the same, see PR78562. */ - if (DECL_IS_BUILTIN (prevailing->decl) - && DECL_IS_BUILTIN (decl)) + if (DECL_IS_UNDECLARED_BUILTIN (prevailing->decl) + && DECL_IS_UNDECLARED_BUILTIN (decl)) continue; int level = warn_type_compatibility_p (TREE_TYPE (prevailing->decl), diff --git i/gcc/print-tree.c w/gcc/print-tree.c index d1150e472d5..f4de67e41d2 100644 --- i/gcc/print-tree.c +++ w/gcc/print-tree.c @@ -1046,7 +1046,7 @@ print_decl_identifier (FILE *file, tree decl, int flags) if (flags & PRINT_DECL_ORIGIN) { - if (DECL_IS_BUILTIN (decl)) + if (DECL_IS_UNDECLARED_BUILTIN (decl)) fputs ("", file); else { diff --git i/gcc/tree-pretty-print.c w/gcc/tree-pretty-print.c index 64ac5ab6cec..4462c1a3ce2 100644 --- i/gcc/tree-pretty-print.c +++ w/gcc/tree-pretty-print.c @@ -2152,7 +2152,7 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, break; case TYPE_DECL: - if (DECL_IS_BUILTIN (node)) + if (DECL_IS_UNDECLARED_BUILTIN (node)) { /* Don't print the declaration of built-in types. */ break; diff --git i/gcc/tree-ssa-ccp.c w/gcc/tree-ssa-ccp.c index 0432fe5513d..23be1af08d4 100644 --- i/gcc/tree-ssa-ccp.c +++ w/gcc/tree-ssa-ccp.c @@ -3586,7 +3586,7 @@ pass_post_ipa_warn::execute (function *fun) continue; tree fndecl = gimple_call_fndecl (stmt); - if (fndecl && DECL_IS_BUILTIN (fndecl)) + if (fndecl && DECL_IS_UNDECLARED_BUILTIN (fndecl)) inform (loc, "in a call to built-in function %qD", fndecl); else if (fndecl) diff --git i/gcc/tree.h w/gcc/tree.h index f43ac9f1942..db8650d9a2d 100644 --- i/gcc/tree.h +++ w/gcc/tree.h @@ -2446,11 +2446,12 @@ extern tree vector_element_bits_tree (const_tree); #define DECL_SOURCE_FILE(NODE) LOCATION_FILE (DECL_SOURCE_LOCATION (NODE)) #define DECL_SOURCE_LINE(NODE) LOCATION_LINE (DECL_SOURCE_LOCATION (NODE)) #define DECL_SOURCE_COLUMN(NODE) LOCATION_COLUMN (DECL_SOURCE_LOCATION (NODE)) -/* This accessor returns TRUE if the decl it operates on was created - by a front-end or back-end rather than by user code. In this case - builtin-ness is indicated by source location. */ -#define DECL_IS_BUILTIN(DECL) \ - (LOCATION_LOCUS (DECL_SOURCE_LOCATION (DECL)) <= BUILTINS_LOCATION) +/* This decl was created by a front-end or back-end rather than by + user code, and has not been explicitly declared by the user -- when + that happens the source location is updated to the user's + source. This includes decls with no location (!). */ +#define DECL_IS_UNDECLARED_BUILTIN(DECL) \ + (DECL_SOURCE_LOCATION (DECL) <= BUILTINS_LOCATION) /* For FIELD_DECLs, this is the RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node that the field is a member of. For VAR_DECL, @@ -6267,9 +6268,8 @@ type_has_mode_precision_p (const_tree t) /* Return true if a FUNCTION_DECL NODE is a GCC built-in function. - Note that it is different from the DECL_IS_BUILTIN accessor. For - instance, user declared prototypes of C library functions are not - DECL_IS_BUILTIN but may be fndecl_built_in_p. */ + Note that it is different from the DECL_IS_UNDECLARED_BUILTIN + accessor, as this is impervious to user declaration. */ inline bool fndecl_built_in_p (const_tree node) diff --git i/gcc/xcoffout.c w/gcc/xcoffout.c index 4e51e62015f..1e72c6e2cef 100644 --- i/gcc/xcoffout.c +++ w/gcc/xcoffout.c @@ -164,7 +164,7 @@ xcoff_assign_fundamental_type_number (tree decl) size_t i; /* Do not waste time searching the list for non-intrinsic types. */ - if (DECL_NAME (decl) == 0 || ! DECL_IS_BUILTIN (decl)) + if (DECL_NAME (decl) == 0 || ! DECL_IS_UNDECLARED_BUILTIN (decl)) return 0; name = IDENTIFIER_POINTER (DECL_NAME (decl)); diff --git i/libcc1/libcc1plugin.cc w/libcc1/libcc1plugin.cc index 8351f2e30dd..241a8158b98 100644 --- i/libcc1/libcc1plugin.cc +++ w/libcc1/libcc1plugin.cc @@ -300,7 +300,7 @@ address_rewriter (tree *in, int *walk_subtrees, void *arg) decl_addr_value *found_value = ctx->address_map.find (&value); if (found_value != NULL) ; - else if (DECL_IS_BUILTIN (*in)) + else if (DECL_IS_UNDECLARED_BUILTIN (*in)) { gcc_address address; diff --git i/libcc1/libcp1plugin.cc w/libcc1/libcp1plugin.cc index d758df8b556..bab2751a5ce 100644 --- i/libcc1/libcp1plugin.cc +++ w/libcc1/libcp1plugin.cc @@ -353,7 +353,7 @@ supplement_binding (cxx_binding *binding, tree decl) /* If TARGET_BVAL is anticipated but has not yet been declared, pretend it is not there at all. */ || (TREE_CODE (target_bval) == FUNCTION_DECL - && DECL_UNDECLARED_BUILTIN_P (target_bval))) + && DECL_IS_UNDECLARED_BUILTIN (target_bval))) binding->value = decl; else if (TREE_CODE (target_bval) == TYPE_DECL && DECL_ARTIFICIAL (target_bval)