From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id 7C3C63857C5A for ; Wed, 23 Sep 2020 21:18:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7C3C63857C5A Received: by mail-oi1-x22b.google.com with SMTP id 26so1366827ois.5 for ; Wed, 23 Sep 2020 14:18:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=WV+9xO+zjEKpHoDIOYw4WFpH6MoFIZSsOyTZCTW6ZQU=; b=HYw82oG8rihPonfQEQKUuNaBqI0jS/3qh7oVlIf3y/3SG+g0ahq+XiCahhujT8uvmv S8ljWyK2tUmcDXA4LdLVNB4M1jVC2YtsxBulrZX5qCakHO/H8HDRwKtOeQZdhB0wsr4U GC6H8fbYeiFMfk6hRkZ7/caln1+c9mTHV6XO3P3e5RtZP3H6h9+H4kdKh5jk22nYYJkA Aq5N8Cxh8isKAj26VyX5IaH5ZJvHeLhvYADht7WhaChaku7t6BvW1mdExEYQFhh+q0rG KX0Iq8ZjHqkQVJcXZZNdUXjNXh9aVGtYDYd6AbPWG8Z+EYHKnF7CaNyzyLS6FOAu3xpb 4ycQ== X-Gm-Message-State: AOAM531cJsWGvyUcde1MbOfDZIVx+fUBYough9qIr7QmO6CFe5wH2jJe jFYwjrA9ZsWJBJOKpCJ7qhqdJznDYFbbQA== X-Google-Smtp-Source: ABdhPJxfyO7+J8fe2h0l0+bi0p/HzWPXnsMFbSuebH28rmyNYzsurNs3/W5gn3HoOe00GNkLqdt74w== X-Received: by 2002:a05:6808:686:: with SMTP id k6mr804834oig.129.1600895896512; Wed, 23 Sep 2020 14:18:16 -0700 (PDT) Received: from [192.168.0.41] (174-16-106-113.hlrn.qwest.net. [174.16.106.113]) by smtp.gmail.com with ESMTPSA id d63sm205483oig.53.2020.09.23.14.18.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 23 Sep 2020 14:18:16 -0700 (PDT) To: gcc-patches From: Martin Sebor Subject: [committed] also test for null in addition to error_mark_node (PR c/97131) Message-ID: <2036d4fe-ccda-952f-35f1-d881e4258ad6@gmail.com> Date: Wed, 23 Sep 2020 15:18:15 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Wed, 23 Sep 2020 21:18:18 -0000 The new warn_parm_ptrarray_mismatch() function can be called even for invalid source code. It tries to handle some of it by checking for error_mark_node but that's not enough since some invalid input can apparently result in nodes being null. I have committed the patch below to avoid the ICE that it causes. Martin commit e92779db3304bc96a6b861f87c5edde8dd4d4030 Author: Martin Sebor Date: Wed Sep 23 15:02:01 2020 -0600 Avoid assuming input corresponds to valid source code (PR c/97131). gcc/c-family/ChangeLog: PR c/97131 * c-warn.c (warn_parm_ptrarray_mismatch): Handle more invalid input. gcc/testsuite/ChangeLog: PR c/97131 * gcc.dg/Warray-parameter-6.c: New test. diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c index d6db85b6de5..ebd011d1a42 100644 --- a/gcc/c-family/c-warn.c +++ b/gcc/c-family/c-warn.c @@ -3181,11 +3181,16 @@ warn_parm_ptrarray_mismatch (location_t origloc, tree curparms, tree newparms) while (TREE_CODE (curtyp) == POINTER_TYPE && TREE_CODE (newtyp) == POINTER_TYPE); + if (!newtyp) + /* Bail on error. */ + return; + if (TREE_CODE (curtyp) != ARRAY_TYPE || TREE_CODE (newtyp) != ARRAY_TYPE) { if (curtyp == error_mark_node || newtyp == error_mark_node) + /* Bail on error. */ return; continue; diff --git a/gcc/testsuite/gcc.dg/Warray-parameter-6.c b/gcc/testsuite/gcc.dg/Warray-parameter-6.c new file mode 100644 index 00000000000..609dac96bb6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/Warray-parameter-6.c @@ -0,0 +1,9 @@ +/* PR c/97131 - ICE: Segmentation fault in warn_parm_ptrarray_mismatch + { dg-do compile } + { dg-options "-Wall" } */ + +struct bm { }; + +void ms (struct bm (*at)[1]) { } + +void ms (int f1) { } // { dg-error "conflicting types for 'ms'" }