From patchwork Thu Oct 12 18:56:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 825032 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-464060-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="vqQXYWPv"; 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 3yCg6z33Fbz9sPm for ; Fri, 13 Oct 2017 05:56:26 +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=Hr0+6nMU4SQavrUX4X7DpRQhBN0RtX7/I3e8cbGwkc9XmyH8Gp xFlcECznGDpVH/lUjQcLLjIvNDjZlNcPQFbFVdhD4cJUSpo2cbpm3G5cvYtnduKf XezfsPXlMb4/fWslUHB3QmVl5XtWDWAHCzJas8lovKz58yaw4zbrBUpYk= 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=wUp/0C+l2u0Bo7zWjoAPDP2xqcU=; b=vqQXYWPvSQgttJGA3dGv ztcZrOXXapT+ZZRND4CqLRIx+2NDTOIS/lryV85m5YRRhNsrFmyvuh4b4enY8aYs FXE/kdXW5pUX9PGFbQ6Wv11C/Peu1Pkk6gTMADxbHizY3hxP410V/2xAzZ9g5a0D 6y+SeCRopogu3vfOaKQtbbo= Received: (qmail 48122 invoked by alias); 12 Oct 2017 18:56:18 -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 48101 invoked by uid 89); 12 Oct 2017 18:56:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=bob X-HELO: mail-qt0-f180.google.com Received: from mail-qt0-f180.google.com (HELO mail-qt0-f180.google.com) (209.85.216.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Oct 2017 18:56:17 +0000 Received: by mail-qt0-f180.google.com with SMTP id f8so15463733qta.5 for ; Thu, 12 Oct 2017 11:56:16 -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=b9TOmGzuWqOZJgHiMDAkDoSjLvlSKjJjsdSXh2KdZtc=; b=k7UWpOByf37jfFoORg8sgBo2M0zCR6fhiC/Cspgz84JBAFxBdNhUzEU2SEFFQ7z15K 3Z7w/pxjDAgDtNb0WEPXurCcbG5lnkcSNI4c3pgE1w6VjsUufJMHVitweOkSAYTYJMNU VxLmxoT0GwR+Uj7WKw1wjSiB970ndaD3isuP2WnRYoc5XgVs0V2gGWVs0JYBZPY1Aej5 DxDjPZXzFPtfAdJIe+mME2VJadBKozPgVXDdRMJHVizfQDkvFIsYQS3ujxvyHl0tEKpM qzGsQQ/R6pl12Q7n3Qw1VfjvnnBIgTZf9rX3jCfphNEZUDjH8PV541hIrzoXNt3lG7IY GAkQ== X-Gm-Message-State: AMCzsaV6RFZlQnSBC34UX0kGg9Id0BXZYK3ru3j9NlmaDkqgRz23SICz vgpYOHlf1faFiOALIKq7SmI= X-Google-Smtp-Source: AOwi7QAJaCQbzmmoJvW7Nf33gDAMsmz9GkQPkV59KoISqTZ0Umyrhx4nW385cC31EbeI4Ro8S70qqw== X-Received: by 10.37.64.6 with SMTP id n6mr2394932yba.491.1507834575010; Thu, 12 Oct 2017 11:56:15 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::7ed9]) by smtp.googlemail.com with ESMTPSA id o184sm6055876ywc.52.2017.10.12.11.56.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Oct 2017 11:56:14 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] cp_expr tweak and delete unused enumerations Message-ID: Date: Thu, 12 Oct 2017 14:56:13 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 The cp_expr class doesn't have a const-qualified operator * accessor. This leaves one with a confusing error message if one ever tries to dereference a constant cp_expr object: const cp_expr thing = ...; tree bob = *thing; // ERROR What happens is the non-const operator * is not suitable, but the implicit conversion to a tree is, which is then dereferenced. so we end up trying to assign a struct to a pointer-to-struct. cp_expr::operator-> has a similar problem. The attached patch adds const-qualified accessors. I also noticed that some of the values of cp_tree_node_structure_enum were no longer used, leading to warnings about them not being handled in switch statements. (We never use LAST_TS_CP_ENUM to size an array). Deleted in this patch. Applying to trunk. nathan 2017-10-12 Nathan Sidwell * cp-tree.h (cp_expr): Add const operator * and operator-> accessors. (cp_tree_node_structure_enum): Delete TS_CP_BINDING, TS_CP_WRAPPER, LAST_TS_CP_ENUM. Index: cp-tree.h =================================================================== --- cp-tree.h (revision 253683) +++ cp-tree.h (working copy) @@ -65,7 +65,9 @@ public: /* Implicit conversions to tree. */ operator tree () const { return m_value; } tree & operator* () { return m_value; } + tree operator* () const { return m_value; } tree & operator-> () { return m_value; } + tree operator-> () const { return m_value; } tree get_value () const { return m_value; } location_t get_location () const { return m_loc; } @@ -1467,11 +1469,9 @@ enum cp_tree_node_structure_enum { TS_CP_IDENTIFIER, TS_CP_TPI, TS_CP_PTRMEM, - TS_CP_BINDING, TS_CP_OVERLOAD, TS_CP_BASELINK, TS_CP_TEMPLATE_DECL, - TS_CP_WRAPPER, TS_CP_DEFAULT_ARG, TS_CP_DEFERRED_NOEXCEPT, TS_CP_STATIC_ASSERT, @@ -1480,8 +1480,7 @@ enum cp_tree_node_structure_enum { TS_CP_LAMBDA_EXPR, TS_CP_TEMPLATE_INFO, TS_CP_CONSTRAINT_INFO, - TS_CP_USERDEF_LITERAL, - LAST_TS_CP_ENUM + TS_CP_USERDEF_LITERAL }; /* The resulting tree type. */