From patchwork Wed Apr 17 17:45:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 1087081 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-499400-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="huGeOrn9"; 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 44kqQc6NW0z9s4Y for ; Thu, 18 Apr 2019 03:45:42 +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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=prq40K4Rr53BR3Fsx/ozI0DXHThzNZCBhcl/evwXZWSmmAKyzT2vN rPhfYdnbBFQ3hF0UOT2eW/Xyw4vtAolqp18CooyS0lIAo3A2O4n7daok1LF/uUS4 pLCBf4ikca/xVqTOT6Njgh4Tj5/QGYPlZgUqxysIFOHLHHB7Yf+k0I= 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:subject:message-id:mime-version:content-type; s= default; bh=5wCGjKRM/zhMgVMcggClvBtdi54=; b=huGeOrn9/ePoaSBoC8Fw qNp6QdHosUKTOGoLNXntuclUStUdxxvtTfwtoUFVfygomEGlzJG48AJPy+HjcKZ8 SSXXwFbo5EwwmLPjdtf8DRYtbx+7jgYdCP3YsTl7owCkqEUWkCw0B2omFD1zlwAq Jp4vDfWzWxDshSJ8PIS8bDk= Received: (qmail 74954 invoked by alias); 17 Apr 2019 17:45:33 -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 74828 invoked by uid 89); 17 Apr 2019 17:45:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 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= 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; Wed, 17 Apr 2019 17:45:22 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5515308A104 for ; Wed, 17 Apr 2019 17:45:17 +0000 (UTC) Received: from redhat.com (unknown [10.20.4.51]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5EFBB608C1; Wed, 17 Apr 2019 17:45:17 +0000 (UTC) Date: Wed, 17 Apr 2019 13:45:15 -0400 From: Marek Polacek To: GCC Patches , Jason Merrill Subject: C++ PATCH for c++/90124 - bogus error with incomplete type in decltype Message-ID: <20190417174515.GD4324@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.11.3 (2019-02-01) This fixes a recent P1. Here we were giving the "invalid use of incomplete type" error, but "the operand of the decltype specifier is an unevaluated operand" and so the objects it names are not required to have a definition. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2019-04-17 Marek Polacek PR c++/90124 - bogus error with incomplete type in decltype. * typeck.c (build_class_member_access_expr): Check cp_unevaluated_operand. * g++.dg/cpp0x/decltype70.C: New test. diff --git gcc/cp/typeck.c gcc/cp/typeck.c index 03b14024738..7224d9bf9ed 100644 --- gcc/cp/typeck.c +++ gcc/cp/typeck.c @@ -2477,7 +2477,8 @@ build_class_member_access_expr (cp_expr object, tree member, /* We didn't complain above about a currently open class, but now we must: we don't know how to refer to a base member before layout is complete. But still don't complain in a template. */ - if (!dependent_type_p (object_type) + if (!cp_unevaluated_operand + && !dependent_type_p (object_type) && !complete_type_or_maybe_complain (object_type, object, complain)) return error_mark_node; diff --git gcc/testsuite/g++.dg/cpp0x/decltype70.C gcc/testsuite/g++.dg/cpp0x/decltype70.C new file mode 100644 index 00000000000..b26aca90651 --- /dev/null +++ gcc/testsuite/g++.dg/cpp0x/decltype70.C @@ -0,0 +1,10 @@ +// PR c++/90124 +// { dg-do compile { target c++11 } } + +class a { +public: + int b; +}; +class c : a { + auto m_fn1() -> decltype(b); +};