From patchwork Fri Oct 18 12:44:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1179342 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-511284-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="I8C2qJOG"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="q34qxcww"; dkim-atps=neutral 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 46vm2j48Jdz9sPV for ; Fri, 18 Oct 2019 23:44:58 +1100 (AEDT) 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=WCgxMjSGyUpLtMQDil8FsMWT6al+kOJT88hkp9NgPrTtu+RSSd 2Bvn7CGBZNgnYcgdyWoYU+qtbdw+9OwrkYtnBPaYYN2m24yBLqq+rKr/hXpH7Un0 jGrs9+aMJtyq/urcIz17oShqGZ4YHQpVGtYNHO1N9zDGsXZ14qcH9Ghl8= 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=pdCsg2KWYjel+xNYMbB6MuyeHx8=; b=I8C2qJOGXFSkYEmmVIb/ ZDQYaV3VvW1fKD64R5wojv2nYlkZDjOHcZghyIKpK82UHukhFhEgAygJefzDzV7Z ObtoBRlYY5t9vSZkFivfEKdqXycbGkoCcQir2wVabMtC0s9I2KqYjpJELXEfZg2A Lxqfs1QGzIoVQKUqxMi08Jg= Received: (qmail 74894 invoked by alias); 18 Oct 2019 12:44:45 -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 73946 invoked by uid 89); 18 Oct 2019 12:44:37 -0000 Authentication-Results: sourceware.org; auth=none 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.1 spammy=H*F:D*acm.org, nathan@acm.org, nathanacmorg, Sidwell X-HELO: mail-qt1-f178.google.com Received: from mail-qt1-f178.google.com (HELO mail-qt1-f178.google.com) (209.85.160.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 18 Oct 2019 12:44:35 +0000 Received: by mail-qt1-f178.google.com with SMTP id c17so5838075qtn.8 for ; Fri, 18 Oct 2019 05:44: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=I+lEtrMDV9muymyYDt2lGx0wNeYp6tTStYLTR2GfRmU=; b=q34qxcwwP1u6YnDUtnhEluFvsm0MlXVJG4PpVOFdN0t8WmPe/gckMvny1u5fUon3cd 21OTH7KNzrOwgkSFKyCSyemdnN0Ewex/DDmoJgH84/PlwozizpZw7/6euAW0tBnYBGsP f8SeJCXFuC3Z7mA3s5o6NV1gXUSxv5NcmY17ywvwdvQVf+id+WVNG2VVoCX5j3nKxd1t l8VkdFZCuvAlbVsuqigi38KP0J5LpCu832MuuLGx5rGlZyftzUPKNNwLkcuTEU7+7lQJ MxbJZdg/EKEq1N879DtpB1BJvnKf8CF0NFVaRDyc0FHK6x/kBDoDFSc88xym3oYezoR8 Gj/A== Received: from ?IPv6:2620:10d:c0a3:1407:f510:fef1:606a:3c63? ([2620:10d:c091:500::3:4737]) by smtp.googlemail.com with ESMTPSA id a19sm3572095qtc.58.2019.10.18.05.44.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Oct 2019 05:44:32 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] anon type names Message-ID: <06870cd2-7866-8feb-2325-508803535a51@acm.org> Date: Fri, 18 Oct 2019 08:44:31 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 I noticed that we use a bitfield flag to note types with names for linkage purposes: typedef struct {} foo; but, we can infer this by comparing TYPE_STUB_DECL and TYPE_DECL of the main variant. It's only checked in two places -- the C++ parser and the objective C++ encoder. Committing this to trunk. nathan 2019-10-18 Nathan Sidwell * cp-tree.h (struct lang_type): Remove was_anonymous. (TYPE_WAS_UNNAMED): Implement by checking TYPE_DECL & TYPE_STUB_DECL. * decl.c (name_unnamed_type): Don't set TYPE_WAS_UNNAMED. Index: gcc/cp/cp-tree.h =================================================================== --- gcc/cp/cp-tree.h (revision 277149) +++ gcc/cp/cp-tree.h (working copy) @@ -2153,5 +2153,4 @@ struct GTY(()) lang_type { unsigned ptrmemfunc_flag : 1; - unsigned was_anonymous : 1; unsigned lazy_default_ctor : 1; unsigned lazy_copy_ctor : 1; @@ -2161,6 +2160,6 @@ struct GTY(()) lang_type { unsigned has_complex_copy_ctor : 1; unsigned has_complex_copy_assign : 1; - unsigned non_aggregate : 1; + unsigned has_complex_dflt : 1; unsigned has_list_ctor : 1; @@ -2170,6 +2169,6 @@ struct GTY(()) lang_type { unsigned lazy_move_assign : 1; unsigned has_complex_move_ctor : 1; - unsigned has_complex_move_assign : 1; + unsigned has_constexpr_ctor : 1; unsigned unique_obj_representations : 1; @@ -2183,5 +2182,5 @@ struct GTY(()) lang_type { of this by updating the size of this bitfield whenever you add or remove a flag. */ - unsigned dummy : 4; + unsigned dummy : 5; tree primary_base; @@ -4586,6 +4585,10 @@ more_aggr_init_expr_args_p (const aggr_i /* Define fields and accessors for nodes representing declared names. */ -/* Nonzero if TYPE is an unnamed class with a typedef for linkage purposes. */ -#define TYPE_WAS_UNNAMED(NODE) (LANG_TYPE_CLASS_CHECK (NODE)->was_anonymous) +/* True if TYPE is an unnamed structured type with a typedef for + linkage purposes. In that case TYPE_NAME and TYPE_STUB_DECL of the + MAIN-VARIANT are different. */ +#define TYPE_WAS_UNNAMED(NODE) \ + (TYPE_NAME (TYPE_MAIN_VARIANT (NODE)) \ + != TYPE_STUB_DECL (TYPE_MAIN_VARIANT (NODE))) /* C++: all of these are overloaded! These apply only to TYPE_DECLs. */ Index: gcc/cp/decl.c =================================================================== --- gcc/cp/decl.c (revision 277149) +++ gcc/cp/decl.c (working copy) @@ -10442,7 +10442,4 @@ name_unnamed_type (tree type, tree decl) TYPE_NAME (t) = decl; - if (TYPE_LANG_SPECIFIC (type)) - TYPE_WAS_UNNAMED (type) = 1; - /* If this is a typedef within a template class, the nested type is a (non-primary) template. The name for the