From patchwork Fri Nov 1 12:57:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 100020 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F3A83858427 for ; Fri, 1 Nov 2024 12:58:30 +0000 (GMT) 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 ESMTP id 215F43858D29 for ; Fri, 1 Nov 2024 12:57:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 215F43858D29 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 215F43858D29 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730465883; cv=none; b=g9NRuYPOSzxlMnkSNy8uNbvWLximU3TxGOlYMmznHNmgvB/MA0VicBTX314vdk9l0N/4vLgCETJq52fk86H7wfPLtGLkLoeBuSo/TcjcgneGhwlLsqtYd5LQY09WeAN7x7jxe/c+sHFwixzZHOF56tpJrEiW2K2jaIPtIuC7tuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730465883; c=relaxed/simple; bh=YaWrpb7lEzmeTdno2TMvKmLJp6rRl21xFGt6HtYjN6o=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=SVpIS2rAnym4NEG6zRtL0MrEQRFR8y/63NKfObT9oi6Ib/UVg480m2pB5CxIsPy9gz6zCJN6wXMw9x2JCOxeGIN8NL+byo0k1YTkttFOFIGaQ3G92Goo7Ai6a833Nh3zkaCzOC8vLmaYpRjYT+AqfcExVkkf/OiamN1LmZHeUzQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730465878; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=D315RABBa317Zd/iZhkpkzPmJvd0dx0IzEo4YyymEh8=; b=aIZsBFVe8rlnAtGytapt1X9Y7xqYs7Clf8JIKupTHwbOx54NvaceOxUAAWDc/p7mHzJA2I botS4pZC2i+RIBaGIwg+yaurnt24NQag8dfiuKS3SlHJ4DuFtaX3ZDv0wMImpbGSaTu+AO 7agaHxvW0AlRuH8NFSMX6tNgDglmArE= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-684-rMRpnzQIMwGQ__NxlBy7GA-1; Fri, 01 Nov 2024 08:57:57 -0400 X-MC-Unique: rMRpnzQIMwGQ__NxlBy7GA-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 96D191955F77 for ; Fri, 1 Nov 2024 12:57:56 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.224.16]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1B1441955F39 for ; Fri, 1 Nov 2024 12:57:55 +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 4A1CvrFu3672225 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT) for ; Fri, 1 Nov 2024 13:57:53 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 4A1CvqCF3672224 for gcc-patches@gcc.gnu.org; Fri, 1 Nov 2024 13:57:52 +0100 Date: Fri, 1 Nov 2024 13:57:52 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Return error_mark_node from tsubst_attribute for errneous varid Message-ID: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.7 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_H3, RCVD_IN_MSPIKE_WL, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org Hi! We incorrectly accept some invalid declare variant cases as if declare variant wasn't there, in particular if a function template has some dependent arguments and variant name lookup fails, because that is during fn_type_unification with complain=tf_none, it just sets it to error_mark_node and doesn't complain further, because it doesn't know the substitution failed (we don't return error_mark_node from tsubst_attribute, just create TREE_LIST with error_mark_node TREE_PURPOSE). The following patch fixes it by returning error_mark_node in that case, then fn_type_unification caller can see it failed and can redo it with explain_p so that errors are reported. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. 2024-11-01 Jakub Jelinek * pt.cc (tsubst_attribute): For "omp declare variant base" attribute if varid is error_mark_node, set val to error_mark_node rather than creating a TREE_LIST with error_mark_node TREE_PURPOSE. * g++.dg/gomp/declare-variant-10.C: New test. Jakub --- gcc/cp/pt.cc.jj 2024-10-25 10:00:29.431768386 +0200 +++ gcc/cp/pt.cc 2024-10-31 10:57:05.855001910 +0100 @@ -12163,7 +12163,10 @@ tsubst_attribute (tree t, tree *decl_p, } OMP_TSS_TRAIT_SELECTORS (tss) = nreverse (selectors); } - val = tree_cons (varid, ctx, chain); + if (varid == error_mark_node) + val = error_mark_node; + else + val = tree_cons (varid, ctx, chain); } /* If the first attribute argument is an identifier, don't pass it through tsubst. Attributes like mode, format, --- gcc/testsuite/g++.dg/gomp/declare-variant-10.C.jj 2024-10-31 11:21:13.962820634 +0100 +++ gcc/testsuite/g++.dg/gomp/declare-variant-10.C 2024-10-31 11:26:59.651011406 +0100 @@ -0,0 +1,56 @@ +// { dg-do compile } + +#pragma omp declare variant (f1) match(user={condition(1)}) // { dg-error "'f1' was not declared in this scope; did you mean 'f2'\\\?" } +void +f2 (int) +{ +} + +void f3 (int); + +#pragma omp declare variant (f3) match(user={condition(1)}) // { dg-error "variant 'void f3\\\(int\\\)' and base 'void f4\\\(long int\\\)' have incompatible types" } +void +f4 (long) +{ +} + +#pragma omp declare variant (f5) match(user={condition(1)}) // { dg-error "there are no arguments to 'f5' that depend on a template parameter, so a declaration of 'f5' must be available" } +template +void +f6 (int) +{ +} + +template +void f7 (int); + +#pragma omp declare variant (f7) match(user={condition(1)}) // { dg-error "no matching function for call to 'f7\\\(long int\\\)'" } +template +void +f8 (long) +{ +} + +#pragma omp declare variant (f9) match(user={condition(1)}) +template +void +f10 (T) // { dg-error "'f9' was not declared in this scope; did you mean 'f8'\\\?" } +{ +} + +template +void f11 (T, int); + +#pragma omp declare variant (f11) match(user={condition(1)}) // { dg-error "variant 'void f11\\\(T, int\\\) \\\[with T = int\\\]' and base 'void f12\\\(T, long int\\\) \\\[with T = int\\\]' have incompatible types" } +template +void +f12 (T, long) +{ +} + +void +test () +{ + f10 (0); // { dg-error "no matching function for call to 'f10\\\(int\\\)'" } + f12 (0, 0L); +}