From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8233F3858401 for ; Sat, 6 Nov 2021 19:30:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8233F3858401 Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-D2yfAp1oP5iV4XptqAraIQ-1; Sat, 06 Nov 2021 15:30:00 -0400 X-MC-Unique: D2yfAp1oP5iV4XptqAraIQ-1 Received: by mail-qk1-f197.google.com with SMTP id j6-20020a05620a288600b0045e5d85ca17so8616587qkp.16 for ; Sat, 06 Nov 2021 12:30:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=jA+V6U6ZKPf8yzhXszBEjZTfP9Kv6DlaKoFpK+YKhLk=; b=21FHOYurxyhhrmuoo8pSoXHS/s5jSKV0Qp2xtdqmXT8unmHhNAd9nnV0+ckb8uMlRI Hy4T3actkjloSbYN725w000sZ/6M9odNARCIpPNkK1MEga3Im07lR6k9m6WDMqBBLsSz swYCv0zeOQq5rucS0GG0rLshWODUB5Ik7V0SJbvB36E0VhN1Pm+lD7LX541SBOly5sos Mj2nzS0Fl3rbrXU2OsREmQfnXT2hqm6fHsVfDuymZs/fabn8o1Zau+n+TVckkO1HDNq+ ntpYXfCtqxaqgFlU4iDW7tfvvb7Pq03jDvvbTzzzVBgjYSNUeqG/wL3raQy1axSWg9UQ eLzQ== X-Gm-Message-State: AOAM530D4J+uZ+RuyaHO+WlXQ/6yzWAZVV5ZmK9Pdbhpqe+zvvS+43kw SsO/VRinOUBl6cPETkLKmoUZKt2LcsaLmRTxHso65tAvF0FLxEFTeEIcJyXlWmFOxf7lbB6lQdV cyxBpwIBVCtpaywBw3Q== X-Received: by 2002:a05:620a:29c4:: with SMTP id s4mr54514982qkp.510.1636226999673; Sat, 06 Nov 2021 12:29:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwL33ROYbb34eaPM6+BvuhhB1NiW5raGdmtw8TaOUkz0ODlVXOR2CObwNh/M07sjt8oh6nrBA== X-Received: by 2002:a05:620a:29c4:: with SMTP id s4mr54514963qkp.510.1636226999390; Sat, 06 Nov 2021 12:29:59 -0700 (PDT) Received: from [192.168.1.149] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id i6sm8099665qkn.14.2021.11.06.12.29.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 06 Nov 2021 12:29:58 -0700 (PDT) Message-ID: <516f3ddd-8634-9d73-ddd4-ae470f4284cf@redhat.com> Date: Sat, 6 Nov 2021 15:29:57 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH v5] attribs: Implement -Wno-attributes=vendor::attr [PR101940] To: Marek Polacek , Bernhard Reutner-Fischer Cc: Marek Polacek via Gcc-patches , Jakub Jelinek References: <20210920170658.28014-1-polacek@redhat.com> <20210920173859.GK304296@tucnak> <20210920190809.GM304296@tucnak> <8636350f-e588-12d1-b687-89245de0b62d@redhat.com> <89690210-3ac3-9486-1fa0-742fc67d3748@redhat.com> <84D9B2CE-EA9B-46FB-9BF5-809D29B7018E@gmail.com> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-14.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , X-List-Received-Date: Sat, 06 Nov 2021 19:30:03 -0000 On 11/6/21 14:28, Marek Polacek wrote: > On Sat, Nov 06, 2021 at 02:32:26AM +0100, Bernhard Reutner-Fischer wrote: >> On 6 November 2021 01:21:43 CET, Marek Polacek via Gcc-patches wrote: >> >>> >>> Thanks, so like this? I'm including an incremental diff so that it's >>> clear what changed: >>> >>> diff --git a/gcc/attribs.c b/gcc/attribs.c >>> index d5fba7f4bbb..addfe6f6c80 100644 >>> --- a/gcc/attribs.c >>> +++ b/gcc/attribs.c >>> @@ -237,7 +237,7 @@ check_attribute_tables (void) >>> the end of parsing of all TUs. */ >>> static vec ignored_attributes_table; >>> >>> -/* Parse arguments ARGS of -Wno-attributes=. >>> +/* Parse arguments V of -Wno-attributes=. >>> Currently we accept: >>> vendor::attr >>> vendor:: >>> @@ -252,12 +252,15 @@ handle_ignored_attributes_option (vec *v) >>> >>> for (auto opt : v) >>> { >>> + /* We're going to be modifying the string. */ >>> + opt = xstrdup (opt); >>> char *q = strstr (opt, "::"); >>> /* We don't accept '::attr'. */ >>> if (q == nullptr || q == opt) >>> { >>> error ("wrong argument to ignored attributes"); >>> inform (input_location, "valid format is % or %"); >>> + free (opt); >>> continue; >>> } >> >> Only xstrdup here, after the strstr check? >> Should maybe strdup the rest here, not full opt.. > > No, I want q to point into the copy of the string, since I'm about > to modify it. And I'd prefer a single call to xstrdup rather than > two. It occurs to me that instead of calling xstrdup at all, since you're already passing the strings to get_identifier you could use get_identifier_with_length instead, and then refer to IDENTIFIER_POINTER of the result. Jason