From patchwork Fri Aug 23 23:18:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1152466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507654-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="S8G2vQ9n"; 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 46Fclt731vz9s7T for ; Sat, 24 Aug 2019 09:18:48 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version :content-transfer-encoding; q=dns; s=default; b=ZeVuqgDrkmXbIty7 wowiNcK8jp5WKumJsHxddPOa8bsQZ6V4flX952rKIh2klqfP2qaDpHQAwH2UE0ns D+pH9BK5DxrppdTTONXgTLWCQJzKFxuisHp8yVDsjFIXWmVYR2dbZmmp2q8saH5+ V/oYvT4drlZ19aEjQ5H1J/YdYCI= 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:from :to:subject:date:message-id:mime-version :content-transfer-encoding; s=default; bh=hqktUaU5fxm1AAVV6MxSdn jJhAI=; b=S8G2vQ9nd2v0QTVllgIO8g0oi37HQCpRmqepDl5r7oLK6DCSVVBCPx wmvVAUORDlMx5iErTRgH+nnK/k9rSuXLbkixUF9186bJri9/G4CJ8EIYA3xC0ymz 215e/jZWZXnYe7aMAlPfIo4wmovhsq4w7IvjnI0VpGSK4B9zyYxUY= Received: (qmail 93028 invoked by alias); 23 Aug 2019 23:18: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 93019 invoked by uid 89); 23 Aug 2019 23:18:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=HContent-Transfer-Encoding:8bit X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Aug 2019 23:18:40 +0000 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA300796E6 for ; Fri, 23 Aug 2019 23:18:38 +0000 (UTC) Received: by mail-qt1-f197.google.com with SMTP id k13so11391442qtp.15 for ; Fri, 23 Aug 2019 16:18:38 -0700 (PDT) Received: from orpheus.redhat.com (75-172-113-80.tukw.qwest.net. [75.172.113.80]) by smtp.gmail.com with ESMTPSA id t5sm2109892qkt.93.2019.08.23.16.18.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2019 16:18:36 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [C++ PATCH 1/2] * parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant error. Date: Fri, 23 Aug 2019 16:18:32 -0700 Message-Id: <20190823231833.30678-1-jason@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes It's rarely useful to give an additional error message about error_mark_node not being something else. Tested x86_64-pc-linux-gnu, applying to trunk. --- gcc/cp/parser.c | 8 +++++--- gcc/cp/ChangeLog | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) base-commit: 9f271cbd097f75318691be869278c2bfa221d780 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 504f77a4908..f80bfc27e76 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6420,9 +6420,11 @@ cp_parser_nested_name_specifier_opt (cp_parser *parser, == CPP_SCOPE)) { token = cp_lexer_consume_token (parser->lexer); - error_at (token->location, "% evaluates to %qT, " - "which is not a class or enumeration type", - token->u.tree_check_value->value); + tree dtype = token->u.tree_check_value->value; + if (dtype != error_mark_node) + error_at (token->location, "% evaluates to %qT, " + "which is not a class or enumeration type", + dtype); parser->scope = error_mark_node; error_p = true; /* As below. */ diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f014423ca00..d07c0de82dd 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-08-22 Jason Merrill + + * parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant + error. + 2019-08-23 Iain Sandoe PR pch/61250 From patchwork Fri Aug 23 23:18:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 1152467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507655-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="XWxLtXoN"; 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 46Fcm4178tz9s7T for ; Sat, 24 Aug 2019 09:18:59 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; q=dns; s=default; b=CQo5PZCZEY8a+mz2 7a2WJJP8ANQ+k4Hgaojj09Gur2CwzjfiICAUTdpQmAsL4BR0JPCJ+Ay4wcJ8bsXa CWfQidJJG2TQT+wwV4zSbmBq1mPBIWAOQMWwi+PGj6elkGBBFTGXIy/6nn0vXlZv FEGfQ7+Z02w3aylBYxj6G2U/TZQ= 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:from :to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=default; bh=K3gg7PFaLOS2Xy5vsJH8ss PaTSs=; b=XWxLtXoNaWA2lEDaZ0hqLy2eD9hyipgHCpgLYcqvWyapCGm7EeI2Pb WXxU5SHPyTIKZ1DtSUYONrS8LNH6Xh+J78plu06WLuFHpw1YVSuvK9GRDRVpi4Mt PpnTKnjXwtJxF6WxPO7RyrjYcPmddIFYd99Y38H8oBCG2KR7NwDs4= Received: (qmail 93201 invoked by alias); 23 Aug 2019 23:18:42 -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 93108 invoked by uid 89); 23 Aug 2019 23:18:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=sk:constex X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Aug 2019 23:18:41 +0000 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B02F583F3B for ; Fri, 23 Aug 2019 23:18:39 +0000 (UTC) Received: by mail-qt1-f198.google.com with SMTP id r10so11439881qte.4 for ; Fri, 23 Aug 2019 16:18:39 -0700 (PDT) Received: from orpheus.redhat.com (75-172-113-80.tukw.qwest.net. [75.172.113.80]) by smtp.gmail.com with ESMTPSA id t5sm2109892qkt.93.2019.08.23.16.18.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2019 16:18:37 -0700 (PDT) From: Jason Merrill To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] Fix handling of namespace-scope undeduced auto decls. Date: Fri, 23 Aug 2019 16:18:33 -0700 Message-Id: <20190823231833.30678-2-jason@redhat.com> In-Reply-To: <20190823231833.30678-1-jason@redhat.com> References: <20190823231833.30678-1-jason@redhat.com> MIME-Version: 1.0 X-IsSubscribed: yes * decl2.c (decl_dependent_p): New. (mark_used): Check it instead of just processing_template_decl. --- gcc/cp/decl2.c | 24 ++++++++++++++++++++- gcc/testsuite/g++.dg/cpp1z/constexpr-if30.C | 10 +++++++++ gcc/cp/ChangeLog | 5 +++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1z/constexpr-if30.C diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index a32108f9d16..134f6d6e3df 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -5407,6 +5407,25 @@ cp_warn_deprecated_use (tree decl, tsubst_flags_t complain) return warned; } +/* True if DECL or its enclosing scope have unbound template parameters. */ + +bool +decl_dependent_p (tree decl) +{ + if (DECL_FUNCTION_SCOPE_P (decl) + || TREE_CODE (decl) == CONST_DECL + || TREE_CODE (decl) == USING_DECL + || TREE_CODE (decl) == FIELD_DECL) + decl = CP_DECL_CONTEXT (decl); + if (tree tinfo = get_template_info (decl)) + if (any_dependent_template_arguments_p (TI_ARGS (tinfo))) + return true; + if (LAMBDA_FUNCTION_P (decl) + && dependent_type_p (DECL_CONTEXT (decl))) + return true; + return false; +} + /* Mark DECL (either a _DECL or a BASELINK) as "used" in the program. If DECL is a specialization or implicitly declared class member, generate the actual definition. Return false if something goes @@ -5433,6 +5452,9 @@ mark_used (tree decl, tsubst_flags_t complain) decl = OVL_FIRST (decl); } + if (!DECL_P (decl)) + return true; + /* Set TREE_USED for the benefit of -Wunused. */ TREE_USED (decl) = 1; /* And for structured bindings also the underlying decl. */ @@ -5480,7 +5502,7 @@ mark_used (tree decl, tsubst_flags_t complain) || DECL_LANG_SPECIFIC (decl) == NULL || DECL_THUNK_P (decl)) { - if (!processing_template_decl + if (!decl_dependent_p (decl) && !require_deduced_type (decl, complain)) return false; return true; diff --git a/gcc/testsuite/g++.dg/cpp1z/constexpr-if30.C b/gcc/testsuite/g++.dg/cpp1z/constexpr-if30.C new file mode 100644 index 00000000000..1e3d15dca1c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/constexpr-if30.C @@ -0,0 +1,10 @@ +// { dg-do compile { target c++17 } } + +auto fn = [](auto i) { + if constexpr (sizeof(i) == 1) + return fn(123); // { dg-error "auto" } +}; + +int main() { + fn('!'); +} diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d07c0de82dd..e6c83b5338e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2019-08-22 Jason Merrill + + * decl2.c (decl_dependent_p): New. + (mark_used): Check it instead of just processing_template_decl. + 2019-08-22 Jason Merrill * parser.c (cp_parser_nested_name_specifier_opt): Avoid redundant