From patchwork Wed Sep 16 15:10:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1365400 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=2620:52:3:1:0:246e:9693:128c; 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=CCJ2PUj9; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4Bs3Sc6dPWz9sSW for ; Thu, 17 Sep 2020 01:10:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 180D73947421; Wed, 16 Sep 2020 15:10:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by sourceware.org (Postfix) with ESMTPS id EB29E386103B for ; Wed, 16 Sep 2020 15:10:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EB29E386103B 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-qk1-x72b.google.com with SMTP id g72so8479040qke.8 for ; Wed, 16 Sep 2020 08:10:35 -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=ReBVJldQGO1SbiHuSNsyRuhRcpwpwCFYNGTXyWFB1Lo=; b=CCJ2PUj9tR6+9mvWTUhnZoRB8eB+bxH0moPNmzVZRGyRcTz5GhPVMxNe6emiooPjUW ZSpyle9AAEqjzFJuODbSYTggjcBqoFPCljG+op5GXBQA4nVmVI9imH99NX4/+vPzOlt2 /+6nr3AgzZg9db5CT9wf+KBbSmX5ke7Zn+d3mnSsYUgHpzSc2QKw+zOap4ZavlxkPOgl tgXAxTlUW/boU668KgVhChJHmKdYyc+8T6jKZCvwTRPl/UW2DFMSD7QhjXT0XsCx/yNk ZGvA4kvc2Xm0v5aY/jUnEqqkL3G16cAdRMVH4eFp+h9uNHO1lbqtEwhwmgUZ0KgcX/0y cFcQ== 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=ReBVJldQGO1SbiHuSNsyRuhRcpwpwCFYNGTXyWFB1Lo=; b=blKugn4NAMNan/TefA+UITlOaQw4pFeTBXE/KleCt+ixQhz579/Y0zNegTyAmOdYrJ Ii3ShaWlUTtxu/2ghjlUNj20nm3oIYjzcdxgCOkzCtfsaODB/eTtHUuF5Hs/T4Boy54g JFNY7TxQ9dky1D2oV9rQXNmXECnX4ICBwjFcUIXyLh/N2Mxps1p050BuxVGzhsDk2ISX bQgO9zYwZLkt3rMMbhGEj5Oh1d1+L5UAz4d3xFu487TUXP1jawIFaloGMvEH/mJqH1Pt H93jntx93QeI1k5ABwY6s+ntAANErYFMiuUw5JLicZaSSG8ojCf/cZx+Ajs0FtMvkamI frYQ== X-Gm-Message-State: AOAM530hj8CzirxRRKvi/YqWazvGn0CRJqZObgpVjQV0nxn4SajdbIIU FAVh6GEj6fZnRC4LZusUpJg= X-Google-Smtp-Source: ABdhPJxEQiyTZf9I8Lo7oDhnf+Gux0eHWx+XHlQpQceWBVMQg8k3S/6EYlKGeYvChPVx1p8JiwK25w== X-Received: by 2002:a37:a143:: with SMTP id k64mr24076119qke.266.1600269035276; Wed, 16 Sep 2020 08:10:35 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:1102:3530:46e6:f8c5:7c9e? ([2620:10d:c091:480::1:c8a7]) by smtp.googlemail.com with ESMTPSA id 18sm19452176qkd.120.2020.09.16.08.10.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Sep 2020 08:10:34 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: c++: Avoid confusing 'nested' name Message-ID: Date: Wed, 16 Sep 2020 11:10:32 -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=-9.4 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" instantiate_body has a local var call 'nested', which indicates that this instantiation was caused during the body of some function -- not necessarily its containing scope. That's confusing, let's just use 'current_function_decl' directly. Then we can also simplify the push_to_top_level logic, which /does/ indicate whether this is an actual nested function. (C++ does not have nested functions, but OMP ODRs fall into that category. A follow up patch will use that more usual meaning of 'nested' wrt to functions.) gcc/cp/ * pt.c (instantiate_body): Remove 'nested' var, simplify push_to_top logic. pushing to trunk diff --git i/gcc/cp/pt.c w/gcc/cp/pt.c index e8aa950b8fa..289452ab740 100644 --- i/gcc/cp/pt.c +++ w/gcc/cp/pt.c @@ -25458,17 +25458,15 @@ instantiate_body (tree pattern, tree args, tree d) tree td = pattern; tree code_pattern = DECL_TEMPLATE_RESULT (td); - tree fn_context = decl_function_context (d); - if (LAMBDA_FUNCTION_P (d)) - /* tsubst_lambda_expr resolved any references to enclosing functions. */ - fn_context = NULL_TREE; - bool nested = current_function_decl != NULL_TREE; - bool push_to_top = !(nested && fn_context == current_function_decl); - vec omp_privatization_save; - if (nested) + if (current_function_decl) save_omp_privatization_clauses (omp_privatization_save); + bool push_to_top + = !(current_function_decl + && !LAMBDA_FUNCTION_P (d) + && decl_function_context (d) == current_function_decl); + if (push_to_top) push_to_top_level (); else @@ -25595,7 +25593,7 @@ instantiate_body (tree pattern, tree args, tree d) else pop_function_context (); - if (nested) + if (current_function_decl) restore_omp_privatization_clauses (omp_privatization_save); }