From patchwork Tue Sep 12 15:25:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 812907 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-461948-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="SCGBfsvu"; 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 3xs7sR6rPGz9s82 for ; Wed, 13 Sep 2017 01:25:31 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=LmheK7P8XPlczHvC3HSJD1BXTUxtpkUSGjs/KFwHyQJk8Bzwt2 YIBMKS0I8lUwSEO4bLcA/FewUxFQDw0ijVBkroFB8UAFxxic+IBX34Nt3+ytOPbb pA7o1SfLq8hw6YLKy/Z3y9oERNSdxX+X55ve9YCMaZXBoCmn0kPeN0q48= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=B2FiN+/vY67N+PYAAltivTezFKw=; b=SCGBfsvu0FcORGxwvFr/ DpJUvgWNyKLKGBMvKj+VXwkHws0XBLpQYD8vD5eK3EI9rlkd8FKkJES3FNXVgpBL WUT+OQqBtioWgS4RxOJ27wQiE30ArW/Q0D9FsXuRUwW+AIf2JYo1h8ackZVMdvD1 GAseu7dJShWaV2VGY3WlBhs= Received: (qmail 130730 invoked by alias); 12 Sep 2017 15:25:25 -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 130717 invoked by uid 89); 12 Sep 2017 15:25:24 -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= X-HELO: mail-yw0-f171.google.com Received: from mail-yw0-f171.google.com (HELO mail-yw0-f171.google.com) (209.85.161.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Sep 2017 15:25:23 +0000 Received: by mail-yw0-f171.google.com with SMTP id s62so28995737ywg.0 for ; Tue, 12 Sep 2017 08:25:23 -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:cc:from:subject:message-id:date :user-agent:mime-version:content-language; bh=ZcRCkTcA0dn80k29GgEuMZjSsL7bcyO2nyLdIEGlGqU=; b=VFJCuFr0JiTBsnDjpxZkv1ADjdfYxhelehQEnmVEjeplC8RiPCIZ+6QC1pX4CUSWTl ODqMcoZfEKtIYN2qshkTmFRJYkAWqbpcXsXCMvAh3C3g9IQHc2hmlEhQ7zkOcULz0pdM DzuncSxNO4hBd65sLJ3PiOB86Wcxmo1scttZmaKspzoY2tw1jTX9AE0v1nPlid+uM8qw eLE4Kaj+mvdiQq9FnOIAozUkv+aHVodyDhY+NZ+lfRq4W/UGlE63oiqkLLerhYm6jNDs 8rUm/uWgYqD4MP4xItjmYnODZfVftVml8WjnLfBD3YoFULSPiIKxi/yz/dcOPlJbmLX0 aL8Q== X-Gm-Message-State: AHPjjUiLlXRUNJXo0nUvsnWP+EvyBg1gYoY4p8kDfFTVQuzYPh7kjCDm jD/4NCnCHA7NFj5/ X-Google-Smtp-Source: AOwi7QC7oCCBgyDE9ZEaSMhql2ZwkCREzuK1zw/k7ETf6rTpLn6ywp8GAm0fD1el88PbXUbGN7axRQ== X-Received: by 10.37.55.143 with SMTP id e137mr12534785yba.124.1505229921521; Tue, 12 Sep 2017 08:25:21 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::a68b]) by smtp.googlemail.com with ESMTPSA id e11sm2248656ywb.105.2017.09.12.08.25.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Sep 2017 08:25:20 -0700 (PDT) To: Joseph Myers Cc: GCC Patches From: Nathan Sidwell Subject: [C PATCH] field_decl_cmp Message-ID: <68b46c41-a333-7273-fe12-ae395d642ccb@acm.org> Date: Tue, 12 Sep 2017 11:25:18 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Joseph, in moving field_decl_cmp to the C FE, I noticed it checks for NULL DECL_NAMES. Those don't occur. This patch removes that checking, and also asserts that when we see identically named decls, exactly one is a TYPE_DECL. ok? nathan 2017-09-12 Nathan Sidwell * c-decl.c (field_decl_cmp): Don't handle NULL names. Refactor. Index: c-decl.c =================================================================== --- c-decl.c (revision 252023) +++ c-decl.c (working copy) @@ -7845,19 +7845,17 @@ warn_cxx_compat_finish_struct (tree fiel static int field_decl_cmp (const void *x_p, const void *y_p) { - const tree *const x = (const tree *) x_p; - const tree *const y = (const tree *) y_p; + const tree x = *(const tree *) x_p; + const tree y = *(const tree *) y_p; - if (DECL_NAME (*x) == DECL_NAME (*y)) - /* A nontype is "greater" than a type. */ - return (TREE_CODE (*y) == TYPE_DECL) - (TREE_CODE (*x) == TYPE_DECL); - if (DECL_NAME (*x) == NULL_TREE) - return -1; - if (DECL_NAME (*y) == NULL_TREE) - return 1; - if (DECL_NAME (*x) < DECL_NAME (*y)) - return -1; - return 1; + if (DECL_NAME (x) != DECL_NAME (y)) + return DECL_NAME (x) < DECL_NAME (y) ? -1 : +1; + + /* If the names are the same, exactly one must be a TYPE_DECL, and + that one is less than (before) the other one. */ + gcc_checking_assert ((TREE_CODE (x) == TYPE_DECL) + != (TREE_CODE (y) == TYPE_DECL)); + return TREE_CODE (x) == TYPE_DECL ? -1 : +1; } /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.