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.129.124]) by sourceware.org (Postfix) with ESMTPS id C4D51385840D for ; Fri, 4 Nov 2022 15:54:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C4D51385840D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667577242; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hd8kPCl+1u/SwAUI6UPOSbUJurRukgXeP4gO1OxruIc=; b=KlJEDUu718U+S8xxneeNpyRJuoSilEH8UuB8bfHOzgSffiS6REx8KieDhK54pm0Dwj6A/8 iKvoyOMhDjqBuBnWUjmCjgAnACVYYzYW12SH6/myeTb5PjbbvBigEkBd6/GG/37qbJrOYj DoLFG37hwxxlWKAo1qA7BXodAQzP5pw= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-605-VJTzQvbhN-ijmzcVExWwbQ-1; Fri, 04 Nov 2022 11:54:01 -0400 X-MC-Unique: VJTzQvbhN-ijmzcVExWwbQ-1 Received: by mail-qt1-f198.google.com with SMTP id ay12-20020a05622a228c00b003a52bd33749so3997778qtb.8 for ; Fri, 04 Nov 2022 08:54:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hd8kPCl+1u/SwAUI6UPOSbUJurRukgXeP4gO1OxruIc=; b=y+g6sChDBfFYjAX5+ig4ldkN5L5wD/3BCR/HpEy+fUctSE4L3wuilhPVFZFu1lf4TV zBDbLnsQdDXRdEEw+y6FpPw6YnoJKU0KcPV6urPalAJ0nwVJjGkwrVYVP9EWeJc3thrd 4Y//w2viQHF+hrWy98TfG+e8Bpm/gCPJPrOvLgMe6h8p4eoRs7Z7DFYBAtxbUhLiXEln pzOHrfdPE+Ga90PruizD2WKr9xfy3Gdti1YHDC9MOn3RUu1fmk/bEoinPD7q7G2kZEyO htenVkVjy08Qq60YyWalWs11Qm0MOvM5lQGNlryXGaPiMYw1tuxjwemvUWXHIJftvVXZ DdPw== X-Gm-Message-State: ACrzQf1nTNfz18PpLhduR2ZQqijJzUval7c6hwMkPk9XB+TPGG7DVk9t 50Djj3Yr0Lmi74mIoihHfPLOJFbx6fT0xV2SxupubKAwEaxJY9UAuqxNAKTm8kaEYnlAQQPvz8B eQ8uKL7oIQmCp1fWeFA== X-Received: by 2002:a05:622a:1491:b0:3a5:74c4:477c with SMTP id t17-20020a05622a149100b003a574c4477cmr407700qtx.505.1667577240750; Fri, 04 Nov 2022 08:54:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5R3JKx9L/JE1z6Fi1oVE87tXGCXwB2AdguhYsifOM9G8vs+s3diuBLu+MSHKh9zYaEHkhpmQ== X-Received: by 2002:a05:622a:1491:b0:3a5:74c4:477c with SMTP id t17-20020a05622a149100b003a574c4477cmr407679qtx.505.1667577240364; Fri, 04 Nov 2022 08:54:00 -0700 (PDT) Received: from t14s.localdomain (c-73-69-212-193.hsd1.nh.comcast.net. [73.69.212.193]) by smtp.gmail.com with ESMTPSA id az18-20020a05620a171200b006bb87c4833asm3070433qkb.109.2022.11.04.08.53.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 08:53:59 -0700 (PDT) Message-ID: Subject: Re: [PATCH 1/6] diagnostics: Fix macro tracking for ad-hoc locations From: David Malcolm To: Lewis Hyatt , gcc-patches@gcc.gnu.org Date: Fri, 04 Nov 2022 11:53:58 -0400 In-Reply-To: <44cead99227a4bbb93860813c168163999b8d164.1667514153.git.lhyatt@gmail.com> References: <44cead99227a4bbb93860813c168163999b8d164.1667514153.git.lhyatt@gmail.com> User-Agent: Evolution 3.44.4 (3.44.4-1.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,BODY_8BITS,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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 List-Id: On Fri, 2022-11-04 at 09:44 -0400, Lewis Hyatt via Gcc-patches wrote: > The result of linemap_resolve_location() can be an ad-hoc location, > if that is > what was stored in a relevant macro map.=C2=A0 > maybe_unwind_expanded_macro_loc() > did not previously handle this case, causing it to print the wrong > tracking > information for an example such as the new testcase macro-trace-1.c.=C2= =A0 > Fix that > by checking for ad-hoc locations where needed. Thanks; looks good to me. Dave >=20 > gcc/ChangeLog: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* tree-diagnostic.cc (may= be_unwind_expanded_macro_loc): > Handle ad-hoc > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0location in return value = of linemap_resolve_location(). >=20 > gcc/testsuite/ChangeLog: >=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0* c-c++-common/cpp/macro-= trace-1.c: New test. > --- > =C2=A0gcc/testsuite/c-c++-common/cpp/macro-trace-1.c | 4 ++++ > =C2=A0gcc/tree-diagnostic.cc=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 | 7 +++++-- > =C2=A02 files changed, 9 insertions(+), 2 deletions(-) > =C2=A0create mode 100644 gcc/testsuite/c-c++-common/cpp/macro-trace-1.c >=20 > diff --git a/gcc/testsuite/c-c++-common/cpp/macro-trace-1.c > b/gcc/testsuite/c-c++-common/cpp/macro-trace-1.c > new file mode 100644 > index 00000000000..34cfbb3dad3 > --- /dev/null > +++ b/gcc/testsuite/c-c++-common/cpp/macro-trace-1.c > @@ -0,0 +1,4 @@ > +/* This token is long enough to require an ad-hoc location. Make > sure that > +=C2=A0=C2=A0 the macro trace still prints properly.=C2=A0 */ > +#define X "0123456789012345678901234567689" /* { dg-error {expected > .* before string constant} } */ > +X /* { dg-note {in expansion of macro 'X'} } */ > diff --git a/gcc/tree-diagnostic.cc b/gcc/tree-diagnostic.cc > index 0d79fe3c3c1..5cf3a1c17d2 100644 > --- a/gcc/tree-diagnostic.cc > +++ b/gcc/tree-diagnostic.cc > @@ -190,14 +190,17 @@ maybe_unwind_expanded_macro_loc > (diagnostic_context *context, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 location_t l =3D=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 linemap_reso= lve_location (line_table, resolved_def_loc, > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 LRK_S= PELLING_LOCATION,=C2=A0 &m); > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (l < RESERVED_LOCATION_COU= NT || LINEMAP_SYSP (m)) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0location_t l0 =3D l; > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (IS_ADHOC_LOC (l0)) > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 l0 =3D get_location_fro= m_adhoc_loc (line_table, l0); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (l0 < RESERVED_LOCATION_COU= NT || LINEMAP_SYSP (m)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 continue; > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=20 > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0/* We need to print the c= ontext of the macro definition only > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 when the loc= us of the first displayed diagnostic > (displayed > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 before this = trace) was inside the definition of the > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 macro.=C2=A0= */ > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int resolved_def_loc_line =3D= SOURCE_LINE (m, l); > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0const int resolved_def_loc_lin= e =3D SOURCE_LINE (m, l0); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ix =3D=3D 0 && saved= _location_line !=3D resolved_def_loc_line) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = diagnostic_append_note (context, resolved_def_loc,=20 >=20