From patchwork Thu Feb 9 08:41:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 54800 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp214197wrn; Thu, 9 Feb 2023 00:42:26 -0800 (PST) X-Google-Smtp-Source: AK7set/DJEmVdV1020ZbotyjgQd7EGXoqT0fldSoPZqlm8ZGoFg1u2MGoILmdGeKMdyxDQU49DJZ X-Received: by 2002:a50:cd48:0:b0:47e:eaae:9a69 with SMTP id d8-20020a50cd48000000b0047eeaae9a69mr10991643edj.41.1675932146620; Thu, 09 Feb 2023 00:42:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675932146; cv=none; d=google.com; s=arc-20160816; b=mJVgFRSecQR0ZzuBl1XdGZmFAZM9TlUPwR0fLuv3LpaJWhZzSD8vLPD4AckZi07Imp cBgOF5ElWMI1TOMenmG/nObRzSX5Uz9U3OFWcmCNlWCk3BYRMDcU/iqpX7qYuk1v5j1w n2h25HZOjw1vjw20zfJC/vCiiyXaRuXrT4YBt9AXOREbKNIBGJNmuD1U6VdLQyaPJwfL MB07tqUPXXGSw90s/LpYdd6WjpgDnXq8SbfPHo1nELudpM7FnjghPTLd9hUzMwnB6CfS YixB47IvOXq1htWO9rnLxfv5YBeFLs/fXkhaq4hjNyPc+9cu6J1Cot1lESyBv4+pdHjG StUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=ssoPR+Xv37uHMUmlkITCui+om2+MOmUSb+xyUpg7t6o=; b=unLbJ2/2NgmkeClk34qu8EpIFIk6u+dxYr1gOe3isVDfI5xAnVRr4N4u90arG0Y/HW IjtN12CciRc95uCraVsO5kfSpMiF4LJzOVcIMCm47QJ+WqWrLsFiW8CDynFMibdS3/EA Ui4oiCnTRDcIt+Ise27s8xOhD7IAUFiwtzi0fk/xYv9lotcFavDcg+QPc0QAWQTuOY7f J/8I3SswSX8cMTp8etrk5ZQyQQhgvb8AGLHr1G+Pyq97e0CR0mKiPFqrIiN44n6ICs7B OgLdoXyMjHkzt5W9TRhl2+vz7vDPFJYb7dAcvUL65dMNXDTOq/g/OFGP1TUv1Y2AQ47U p4zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j2nyVP1s; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u12-20020aa7d0cc000000b004a2337fb41fsi1524665edo.436.2023.02.09.00.42.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 00:42:26 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=j2nyVP1s; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6C44F385841D for ; Thu, 9 Feb 2023 08:42:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C44F385841D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675932145; bh=ssoPR+Xv37uHMUmlkITCui+om2+MOmUSb+xyUpg7t6o=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=j2nyVP1sHTf7sLNsRjdwN2zly9fyX5Aw7hWBEFKH9/smYorwQ1AlZCXr8VSWqrA89 7tG3KItTgAv02hpnckjPn8OWTc5YgpnmCNlDCHvSiHNkjy/N4jfoiM4HtnvlwYt2UO aQn3pTeTDudPXAfremz+PkN7fcowV8op3Nz06Tp0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 888663858C50 for ; Thu, 9 Feb 2023 08:41:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 888663858C50 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-FayNPbFxNpq4wHvNxIp9Zw-1; Thu, 09 Feb 2023 03:41:39 -0500 X-MC-Unique: FayNPbFxNpq4wHvNxIp9Zw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF8A3802314 for ; Thu, 9 Feb 2023 08:41:38 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A45CC16022; Thu, 9 Feb 2023 08:41:38 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 3198fUpQ1915818 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 9 Feb 2023 09:41:31 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 3198fUfK1915817; Thu, 9 Feb 2023 09:41:30 +0100 Date: Thu, 9 Feb 2023 09:41:30 +0100 To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] c++, debug: Fix up locus of DW_TAG_imported_module [PR108716] Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757342226239910535?= X-GMAIL-MSGID: =?utf-8?q?1757342226239910535?= Hi! Before IMPORTED_DECL has been introduced in PR37410, we used to emit correct DW_AT_decl_line on DW_TAG_imported_module on the testcase below, after that change we haven't emitted it at all for a while and after some time started emitting incorrect locus, in particular the location of } closing the function. The problem is that while we have correct EXPR_LOCATION on the USING_STMT, when genericizing that USING_STMT into IMPORTED_DECL we don't copy the location to DECL_SOURCE_LOCATION, so it gets whatever input_location happens to be when it is created. The following patch fixes that, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-02-09 Jakub Jelinek PR debug/108716 * cp-gimplify.cc (cp_genericize_r) : Set DECL_SOURCE_LOCATION on IMPORTED_DECL to expression location of USING_STMT or input_location. * g++.dg/debug/dwarf2/pr108716.C: New test. Jakub --- gcc/cp/cp-gimplify.cc.jj 2023-02-01 10:19:43.038140336 +0100 +++ gcc/cp/cp-gimplify.cc 2023-02-08 10:36:00.301501540 +0100 @@ -1514,6 +1514,8 @@ cp_genericize_r (tree *stmt_p, int *walk tree using_directive = make_node (IMPORTED_DECL); TREE_TYPE (using_directive) = void_type_node; DECL_CONTEXT (using_directive) = current_function_decl; + DECL_SOURCE_LOCATION (using_directive) + = cp_expr_loc_or_input_loc (stmt); IMPORTED_DECL_ASSOCIATED_DECL (using_directive) = decl; DECL_CHAIN (using_directive) = BLOCK_VARS (block); --- gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C.jj 2023-02-08 11:48:39.667385750 +0100 +++ gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C 2023-02-08 11:48:57.998115610 +0100 @@ -0,0 +1,14 @@ +// PR debug/108716 +// { dg-options "-O0 -gdwarf-5 -dA -fno-merge-debug-strings" } +// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_imported_module\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*0xc\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*(\[^\n\r\]*0x13\[^\n\r\]* DW_AT_decl_column\[^\n\r\]*\[\n\r]*)?" } } + +namespace M { + int x = 1; +} + +int +main () +{ + using namespace M; + return 0; +}