From patchwork Tue Nov 12 00:02:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1193203 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-513016-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="V3OWmiYx"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="gt7Fs3OE"; 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 47Bnxm2LWCz9sP3 for ; Tue, 12 Nov 2019 11:02:49 +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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=i9m 4OPtxNA5JzgfLS17paRMSRejYdRMAtVtbbTouezroJxbakHy69WISwkVZOkfoNLJ hWYkEnotEeH9XMN8A4Q9vhrWsn/v0qDABMgJwjNGobehXEw+EKNC2UXbkOyAsHwv 7QYredRJeL9aL7aP0blPvVD9HQlX1z6WVYLdcsaQ= 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:date :from:to:cc:subject:message-id:reply-to:mime-version :content-type:content-transfer-encoding; s=default; bh=Chzpp1DeB eJy7u1uZXMCbw3lBJ8=; b=V3OWmiYxd+spHS8fEsl29qa7oYH4BmVQ2vUnTexfA IJ6axbx8D8224536eywdO0avaZ1iwCzVViDR6M/NnoIV7iT101GDOaMHB0uB8wTS EEvAoQodTTJKkSaqN+GkBl4NpwHLbKkQUSEg8SxWdPOTqv0Mx1A3mYiUyZY5WlBz xA= Received: (qmail 111249 invoked by alias); 12 Nov 2019 00:02:41 -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 111132 invoked by uid 89); 12 Nov 2019 00:02:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 12 Nov 2019 00:02:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573516956; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5nLWrMEnmOF81h1bgreettg3jVBTGdcVT2r4fevZgdw=; b=gt7Fs3OEo4oayMSx+nRsz1JMjFHT3reF97GPsfRvpT66shNXBWM1qjP7JpPE7VGXrVS99I DMCKufJfycCRL8oDpeO3m+TdrmXCoJW5Q5JcvKuDiigYd3kKACfopaKBgSoJouFekp0J4Z +uitEM+Jjw35SjNv9JcNCgni+8wbtUc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-352-PJVcxr2INvmCJbyNcCaWEQ-1; Mon, 11 Nov 2019 19:02:34 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EBC10107ACFA for ; Tue, 12 Nov 2019 00:02:33 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.36.118.135]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7EB8910027B3; Tue, 12 Nov 2019 00:02:33 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id xAC02Ved010307; Tue, 12 Nov 2019 01:02:31 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id xAC02UwI010306; Tue, 12 Nov 2019 01:02:30 +0100 Date: Tue, 12 Nov 2019 01:02:30 +0100 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org Subject: [C++ PATCH] Fix concepts vs. PCH (PR c++/92458) Message-ID: <20191112000230.GC4650@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Mimecast-Spam-Score: 0 Content-Disposition: inline X-IsSubscribed: yes Hi! PCH remaps object addresses, so hash tables that use pointer hashing don't work well across PCH, because the hash values can change and without rehashing the hash tbales values might not be found. The following patch fixes it by using DECL_UID as hash function instead, which is stable across PCH save/restore. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2019-11-11 Jakub Jelinek PR c++/92458 * constraint.cc: Include tree-hash-traits.h. (decl_tree_cache_traits): New type. (decl_tree_cache_map): New typedef. (decl_constraints): Change type to decl_tree_cache_map * from tree_cache_map *. * g++.dg/pch/pr92458.C: New test. * g++.dg/pch/pr92458.Hs: New test. Jakub --- gcc/cp/constraint.cc.jj 2019-11-07 09:50:51.755239234 +0100 +++ gcc/cp/constraint.cc 2019-11-11 19:04:03.231862024 +0100 @@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. #include "decl.h" #include "toplev.h" #include "type-utils.h" +#include "tree-hash-traits.h" static tree satisfaction_value (tree t); @@ -1113,7 +1114,10 @@ build_constraints (tree tr, tree dr) /* A mapping from declarations to constraint information. */ -static GTY ((cache)) tree_cache_map *decl_constraints; +struct decl_tree_cache_traits + : simple_cache_map_traits { }; +typedef hash_map decl_tree_cache_map; +static GTY ((cache)) decl_tree_cache_map *decl_constraints; /* Returns the template constraints of declaration T. If T is not constrained, return NULL_TREE. Note that T must be non-null. */ --- gcc/testsuite/g++.dg/pch/pr92458.C.jj 2019-11-11 19:09:51.547614022 +0100 +++ gcc/testsuite/g++.dg/pch/pr92458.C 2019-11-11 19:12:39.164088578 +0100 @@ -0,0 +1,5 @@ +// PR c++/92458 +// { dg-options "-std=c++2a" } + +#include "pr92458.H" +S s; --- gcc/testsuite/g++.dg/pch/pr92458.Hs.jj 2019-11-11 19:09:25.091012637 +0100 +++ gcc/testsuite/g++.dg/pch/pr92458.Hs 2019-11-11 19:12:47.626961060 +0100 @@ -0,0 +1,7 @@ +// PR c++/92458 +// { dg-options "-std=c++2a" } + +template concept C = sizeof(T) > 1; +template struct S { }; +template requires C struct S { }; +template requires (!C) struct S { };