From patchwork Fri Mar 15 13:28:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 1057008 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-497958-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="u0lKS5aR"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="OfuDnCIz"; 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 44LRHp3VZlz9s3l for ; Sat, 16 Mar 2019 00:29:08 +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:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=VP7pPbCeJ28EThDKegXuhzQnKZ2IfPAiK2hrbMwAp2ILwvzIQC tojs2IczgyLKgpXCAbL8SkFsPs9NqOu2S/OB1S+DYM7joMnBlWb54+IQAyIMFH0Q LRVrqccEl/NcCKD/9wp81MvSoNr/Sc8YT9jOj2CfW3JFRMcsGDGGLRSqg= 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=DKbSzpuLveeJITLc6s/5xD+cN+E=; b=u0lKS5aRc2iRTVQDmj60 412VILgybOQmIinsUanqpHBINVoHdzDg4tHyRiOlrlve1OoxHefcp+gJ3aDQc2fn 4KijQRR955znQuFgjxIWasGji/SPitxaegc0mjuCDGdFtC+YA24ltOw3pf1bfPrL GKLDzAsVkFg4hd7p01+S2+U= Received: (qmail 22614 invoked by alias); 15 Mar 2019 13:29:00 -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 22603 invoked by uid 89); 15 Mar 2019 13:28:59 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=sk:qualify, standing X-HELO: userp2120.oracle.com Received: from userp2120.oracle.com (HELO userp2120.oracle.com) (156.151.31.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Mar 2019 13:28:58 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2FDONgs044436; Fri, 15 Mar 2019 13:28:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=to : cc : from : subject : message-id : date : mime-version : content-type; s=corp-2018-07-02; bh=tcy/eepa345gMRkATU2oLQ5QyU2zeRm6lKPVJQAKpa4=; b=OfuDnCIzeCONx5lOOWhmcWrb1FBrT5p2wGz4PFYAR1kcRxUOeayMv+LX8rb4B4XGvRxd DI/VQzh89PzABhwHvEQ23ZTzKx7Nn9QRgzQkiG5SuD/0k8m3nHMqyt+8M5oOnKOOXzrZ kav+VUFYEVJ1Q5Fp3ct/NMfd4Qr9SaCD17b7sWKYj/5HevEehO9DmTzoA99XzR+VvNeO wbyBN+FwwH8mVHDw4xAngl9Ns+n38SHUkYAwOsJRW1tfsWXOPXuijqwLN0T32Iyy9sHK Ip469bT0LZVP7AywzEztSMj2YfYcYUq1dKOFjVbqkE8XDBxndk3FO4ikfQ7EwEohRbKg WA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2r464rxkpa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Mar 2019 13:28:56 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2FDSo4D018970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Mar 2019 13:28:51 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x2FDSolP029457; Fri, 15 Mar 2019 13:28:50 GMT Received: from [192.168.1.4] (/79.55.91.166) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 15 Mar 2019 13:28:49 +0000 To: "gcc-patches@gcc.gnu.org" Cc: Jason Merrill From: Paolo Carlini Subject: [C++ Patch] PR 85014 ("[7/8/9 Regression] internal compiler error: in lookup_base, at cp/search.c:185") Message-ID: <07a88118-55bf-a1e0-08d0-9d7f0bef2fbf@oracle.com> Date: Fri, 15 Mar 2019 14:28:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 X-IsSubscribed: yes Hi, another - rather long standing - error-recovery regression, where, in some rather special circumstances, we end up passing the FUNCTION_DECL representing the operator () of the lambda to maybe_dummy_object and obviously we almost immediately crash. Not sure how much we want to dig - but simply checking that context_for_name_lookup is actually returning a type appears to work fine, the error_mark_node then propagates back to cp_parser_late_parse_one_default_arg and so on. In the special circumstances of the testcase, context_for_name_lookup finds ANON_AGGR_TYPE_P set for the DECL_CONTEXT of 'b' and iterates to its TYPE_CONTEXT which is the FUNCTION_DECL representing the operator () of the lambda. This is because we just called check_tag_decl on that anonymous type as part of calling shadow_tag on the abstract declaration. Tested x86_64-linux. Thanks, Paolo. //////////////////// /cp 2019-03-15 Paolo Carlini PR c++/85014 * semantics.c (finish_non_static_data_member): Check return value of context_for_name_lookup and immediately return error_mark_node if isn't a type. /testsuite 2019-03-15 Paolo Carlini PR c++/85014 * g++.dg/cpp0x/pr85014.C: New. Index: cp/semantics.c =================================================================== --- cp/semantics.c (revision 269693) +++ cp/semantics.c (working copy) @@ -1828,7 +1828,15 @@ finish_non_static_data_member (tree decl, tree obj { tree scope = qualifying_scope; if (scope == NULL_TREE) - scope = context_for_name_lookup (decl); + { + scope = context_for_name_lookup (decl); + if (!TYPE_P (scope)) + { + /* Can happen during error recovery (c++/85014). */ + gcc_assert (seen_error ()); + return error_mark_node; + } + } object = maybe_dummy_object (scope, NULL); } Index: testsuite/g++.dg/cpp0x/pr85014.C =================================================================== --- testsuite/g++.dg/cpp0x/pr85014.C (nonexistent) +++ testsuite/g++.dg/cpp0x/pr85014.C (working copy) @@ -0,0 +1,10 @@ +// { dg-do compile { target c++11 } } +// { dg-options "" } + +struct { + short a[__builtin_constant_p([] { + struct { + int b = b; + }; // { dg-error "abstract declarator" } + })]; +}; // { dg-error "abstract declarator" }