From patchwork Sun Nov 3 22:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lewis Hyatt X-Patchwork-Id: 2005822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=EHxi+PQE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XhTfw1NWwz1xxN for ; Mon, 4 Nov 2024 09:24:40 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64D53385773C for ; Sun, 3 Nov 2024 22:24:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by sourceware.org (Postfix) with ESMTPS id 12296385842D for ; Sun, 3 Nov 2024 22:22:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12296385842D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 12296385842D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::f2e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730672579; cv=none; b=FhDp+wRfXOwV3suFDZU5dw26mrL6POvwHqq7k5YQ97WqXKeIBGtrxAQ452TLogttL7w+CF5HxWUAlsqQ+WkHrnSWILl/QVsxOXHgwGculHkPPwxV1uFNbXUSZp46ZIBYvOd6k3RxKLNifrJQ9MDUmtdayoj3y4uMTRQ3Wr/0p6w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730672579; c=relaxed/simple; bh=HGtzUKXOSiXfTWMpqeAHVmqbXhGOftgPNsheoSa5kNk=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=i38suL8x/70z8SJiVAt5zhtObeDzwXEhBOHOOtCqsDjll9n+3eZ44MNVv7MHAw8WAMMWwWRwt4dCf/rkETPqS9nf6IIGyWXxvr7r/DFZt5x47tsRFZuYcvnuxIw9hicuH5gNOp+xLqYcR659bB1ud1GdN4y7F35HweBobvCoTtU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-6cc250bbc9eso30676046d6.2 for ; Sun, 03 Nov 2024 14:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730672567; x=1731277367; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5x4xBDFOdammAkxeNrXV7KUjyA0B/B4uM2wtumEiUwA=; b=EHxi+PQEjqZoCWuYFTPzvxeS4QhBBLh1y/BfRrFreMDm7tWoW/ZL1xuHJnjjSbd50W BYkpu3GXep+ZIyMJv240U+4qnZAioCz2YGZZA9CtUyvwq9Gxpmle+laBLztmPvOA4ZIP lmcrt0psfmYdSBiCNwRCZDW58i1Pzmr9qgthwd7IMjfUuwz1KF4C/KuvcXBNfaoCk9Wy qq7kejrg931fD152B/64n3aPR6OEh84r4QjRk+mWIpfZC+79xK6+LD/zvERPGMUQUWm3 4k7cjCpQUEvcq09BckH2TRVsDeH3fVyYMlsMJsrnRAPWuhSV+P8jVDUUS07FoBOUYJqw FSEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730672567; x=1731277367; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5x4xBDFOdammAkxeNrXV7KUjyA0B/B4uM2wtumEiUwA=; b=q4UsZ+skBG82UtdZXVkj2awL7M5U3ySoVtOmxaLXzPaBk38DojiZxmq1KYKYk4GetT P/LikrF9Cg7muyhSway8oaC+/u17vPrmaftGzzyhlWH0iuy67tkxtsb76D271/cbw3a2 m5FUAXuJIikDcSeCbYi3wWdGmx21xhtEeIEqORi0mL6llHavw+nLferLqXJir6E38UMe mqJn+eHHcKcs04Cra9uT/r0ZE36QSlpnrs87zyq+6qsHWebESpXVoeHeG9xTmSTR7Kn9 HA8xDtMi0RlzuM1YhIM+rWlI1aD5L/8BMrn0jd9XsGv4WVBsiQpN3qhZNfSAZOsgVnw8 dN5Q== X-Gm-Message-State: AOJu0Yz36o9hlZILtUIepXDS0ePTvVgrx7tZsjvmlswN6AORic+DPi1Y P6s9LOpfgr7PmqLmtJnjPSWmlaI5bQZlz7kDQDs7AnfnDf9zGtdIY7uWkQ== X-Google-Smtp-Source: AGHT+IHicWXErvg/3AXIZL5TeZOtvxS1QTuD3N14m/+rDED85u/RkrTnX5eNY0q0OTi1sBbX1WeLEw== X-Received: by 2002:a05:6214:3f88:b0:6c7:5e6d:3f79 with SMTP id 6a1803df08f44-6d351b2fb6dmr190727256d6.48.1730672567417; Sun, 03 Nov 2024 14:22:47 -0800 (PST) Received: from localhost.localdomain ([173.54.240.58]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d35415b2fesm42025866d6.92.2024.11.03.14.22.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Nov 2024 14:22:46 -0800 (PST) From: Lewis Hyatt To: gcc-patches@gcc.gnu.org Cc: Lewis Hyatt Subject: [PATCH 05/15] c++: Fix tree_contains_struct for TRAIT_EXPR Date: Sun, 3 Nov 2024 17:22:10 -0500 Message-Id: <20241103222220.933471-6-lhyatt@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241103222220.933471-1-lhyatt@gmail.com> References: <20241103222220.933471-1-lhyatt@gmail.com> MIME-Version: 1.0 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org CODE_CONTAINS_STRUCT () currently reports that a TRAIT_EXPR contains a TS_EXP struct, but it does not actually start with a TS_EXP as an initial sequence. In modules.cc, when we stream out a tree, we explicitly check for the TS_EXP case and call note_location(t->exp.locus) if so. Currently, this actually queries the tree_common::chain field of a tree_trait_expr, which seems not to be used, returning 0, which is interpreted as UNKNOWN_LOCATION and does no harm. If location_t has been configured to be 64 bytes, then on 32-bit platforms (well those, such as sparc, on which uint64_t has higher alignment requirement than a pointer), reading t->exp.locus ends up reading a different field (tree_trait_expr::type1) due to padding offsets. That field is not generally 0, and the resulting bogus location_t is sufficiently problematic to cause an ICE in the line_map code. Pretty much any modules testcase displays the issue, such as partial-2_a.C. Resolve by initializing tree_contains_struct with the correct value for TRAIT_EXPR, namely TS_TYPED. gcc/cp/ChangeLog: * cp-objcp-common.cc (cp_common_init_ts): Change TRAIT_EXPR from TS_EXP to TS_TYPED. --- gcc/cp/cp-objcp-common.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc index 7a0636f1653..1e43db31db8 100644 --- a/gcc/cp/cp-objcp-common.cc +++ b/gcc/cp/cp-objcp-common.cc @@ -617,6 +617,7 @@ cp_common_init_ts (void) MARK_TS_TYPED (PTRMEM_CST); MARK_TS_TYPED (LAMBDA_EXPR); MARK_TS_TYPED (TYPE_ARGUMENT_PACK); + MARK_TS_TYPED (TRAIT_EXPR); /* Random new trees. */ MARK_TS_COMMON (BASELINK); @@ -684,7 +685,6 @@ cp_common_init_ts (void) MARK_TS_EXP (TAG_DEFN); MARK_TS_EXP (TEMPLATE_ID_EXPR); MARK_TS_EXP (THROW_EXPR); - MARK_TS_EXP (TRAIT_EXPR); MARK_TS_EXP (TYPEID_EXPR); MARK_TS_EXP (TYPE_EXPR); MARK_TS_EXP (UNARY_PLUS_EXPR);