From patchwork Thu May 11 14:42:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 761111 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wNwn40Zsdz9s8V for ; Fri, 12 May 2017 00:42:31 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="FHTCnhCz"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=CSN5ghGkM96hiAuO+ifflNVwuLK5N6P9VegL+F4kalCmLwQWmT w+hueW6pYdAnq0VVCEIxHRDvZHuWAJvmgpEq5MsrvLrkxoVuApNQwXd+86l/r0cx Shjsnor7HM+yhtF1ksHvPJ5yMaNJaSo5a/NN5PS7KyzAFi3X3EPCcohes= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=VLVP847K3TIsTS+vKn8MXf6ryhI=; b=FHTCnhCzOEEDDetpa5hh ptEJ4OcP6Vw0Qb7JFx1O7ByKiq/2qzPSUx/rIHx7J/lRh6aSeDIE3g44sBckTfkb /8hHy9XYxZmLKuyS4yWlH505VZxOImF7jqED8xgf1SUaAeU/gpbCheCUumZ8NwOY hESZweYvKsk0XVTtgnR8ijk= Received: (qmail 33563 invoked by alias); 11 May 2017 14:42:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 33544 invoked by uid 89); 11 May 2017 14:42:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yb0-f180.google.com Received: from mail-yb0-f180.google.com (HELO mail-yb0-f180.google.com) (209.85.213.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 11 May 2017 14:42:12 +0000 Received: by mail-yb0-f180.google.com with SMTP id p143so6968153yba.2 for ; Thu, 11 May 2017 07:42:15 -0700 (PDT) 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=vEGnRxAa55mIiRxtAwjvOkUfzMhnNkPqiFPSsnTpDx8=; b=tNDIFOLoiAc67Vf/1KUuOb7XywpkCRDVcm6YuWVcj6yAPorsO+OvsT+GblpbtG01te F1fO677NWuguBp+q6JVoPCu+VHPWVIbGlqjPX7eKjZ67l3f/JBCkNtWEKFrb9iIHlLEL JU/T4OK23g7Mq5BX+neQl6s7R11sTldU0f+bG4zR37CGiQNBVAZiagOlnoDGFrJw8aAz C0UMh5claRv+DG9h8u/kdpEafbBvsNP+H0dRGiTeoAwKMTd+KChOkUUFvgPnAHYPLh5q ZoU3bXxOgBInm7a78agSbMKwrB5AhLSpR0jk0YCYZBjvV5ZsZ+DkHpsYWQRHBZLyJ5IS H8xA== X-Gm-Message-State: AODbwcAdmu+zLF6hHImBXvZK3dZDNpgmlLLszeXKLbi+GcPrn2fS1RAw 1ptjUdDTiibgkA== X-Received: by 10.37.217.75 with SMTP id q72mr602585ybg.32.1494513733639; Thu, 11 May 2017 07:42:13 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:f6d0:5ac5:64cd:f102? ([2620:10d:c091:200::7:4a1a]) by smtp.googlemail.com with ESMTPSA id y75sm169383ywg.31.2017.05.11.07.42.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 11 May 2017 07:42:12 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] xref lambda types Message-ID: <70fb2a4f-811b-cf02-857e-b17f6aa01913@acm.org> Date: Thu, 11 May 2017 10:42:11 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 We were frobing lamda scopes to regular classes when pushing them, but with a few tweaks name lookup can cope directly. nathan 2017-05-11 Nathan Sidwell * decl.c (xref_tag_1): Don't frob ts_lambda scope here. * name-lookup.c (pushtag_1): Deal with ts_lambda scope. Index: decl.c =================================================================== --- decl.c (revision 247908) +++ decl.c (working copy) @@ -13514,12 +13514,10 @@ lookup_and_check_tag (enum tag_types tag static tree xref_tag_1 (enum tag_types tag_code, tree name, - tag_scope orig_scope, bool template_header_p) + tag_scope scope, bool template_header_p) { enum tree_code code; - tree t; tree context = NULL_TREE; - tag_scope scope; gcc_assert (identifier_p (name)); @@ -13539,19 +13537,12 @@ xref_tag_1 (enum tag_types tag_code, tre gcc_unreachable (); } - if (orig_scope == ts_lambda) - scope = ts_current; - else - scope = orig_scope; - /* In case of anonymous name, xref_tag is only called to make type node and push name. Name lookup is not required. */ - if (anon_aggrname_p (name)) - t = NULL_TREE; - else - t = lookup_and_check_tag (tag_code, name, - scope, template_header_p); - + tree t = NULL_TREE; + if (scope != ts_lambda && !anon_aggrname_p (name)) + t = lookup_and_check_tag (tag_code, name, scope, template_header_p); + if (t == error_mark_node) return error_mark_node; @@ -13617,9 +13608,8 @@ xref_tag_1 (enum tag_types tag_code, tre { t = make_class_type (code); TYPE_CONTEXT (t) = context; - if (orig_scope == ts_lambda) - /* Remember that we're declaring a lambda to avoid bogus errors - in push_template_decl. */ + if (scope == ts_lambda) + /* Mark it as a lambda type. */ CLASSTYPE_LAMBDA_EXPR (t) = error_mark_node; t = pushtag (name, t, scope); } Index: name-lookup.c =================================================================== --- name-lookup.c (revision 247908) +++ name-lookup.c (working copy) @@ -6079,7 +6079,9 @@ pushtag_1 (tree name, tree type, tag_sco view of the language. */ || (b->kind == sk_template_parms && (b->explicit_spec_p || scope == ts_global)) + /* Pushing into a class is ok for lambdas or when we want current */ || (b->kind == sk_class + && scope != ts_lambda && (scope != ts_current /* We may be defining a new type in the initializer of a static member variable. We allow this when @@ -6102,9 +6104,10 @@ pushtag_1 (tree name, tree type, tag_sco tree cs = current_scope (); if (scope == ts_current + || scope == ts_lambda || (cs && TREE_CODE (cs) == FUNCTION_DECL)) context = cs; - else if (cs != NULL_TREE && TYPE_P (cs)) + else if (cs && TYPE_P (cs)) /* When declaring a friend class of a local class, we want to inject the newly named class into the scope containing the local class, not the namespace @@ -6138,7 +6141,8 @@ pushtag_1 (tree name, tree type, tag_sco if (b->kind == sk_class) { - if (!TYPE_BEING_DEFINED (current_class_type)) + if (!TYPE_BEING_DEFINED (current_class_type) + && scope != ts_lambda) return error_mark_node; if (!PROCESSING_REAL_TEMPLATE_DECL_P ()) @@ -6189,6 +6193,7 @@ pushtag_1 (tree name, tree type, tag_sco vec_safe_push (local_classes, type); } } + if (b->kind == sk_class && !COMPLETE_TYPE_P (current_class_type)) {