From patchwork Fri Jan 15 15:56:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 568182 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 112451402E2 for ; Sat, 16 Jan 2016 02:56:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=CTKThFN5; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=gDMcmZNPQVqsIIGcLpEgg8USC/T2JhjM3hWPvSUEOVIOoWTbV9 uE9hOD3xSp7LbrrCt7r5sHPFz8kGfKHD4lakuV0aq26WD/rShAIJU1HIsfcNBv+F LIpyZ7qjDYpBVYtSIXc2emcQ1HSTvvWbfrkcplHdmsehKrCAi5rtiXrsg= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=ed74uvzDA6ND7e9ZFTVVjjtsd+4=; b=CTKThFN5rZ8M0gHaAlr3 YzQCYNTHdGdWr1+apVDnV/TJo+HcszUOTSlhmb1nrJabPoaCSnwPy7dZk4nEnPhr MtiQrvnFgqsTVOV+Jt4J+yeYFl6jBjYCcPavoEnnl541WKp640cD+v/7bbiKFqIA FtI+qcbUfzO7zWohpj/cyWs= Received: (qmail 75177 invoked by alias); 15 Jan 2016 15:56:16 -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 75163 invoked by uid 89); 15 Jan 2016 15:56:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=TYPE_NAME, type_name, contextual, adr 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 15 Jan 2016 15:56:13 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 4AC8DA1733 for ; Fri, 15 Jan 2016 15:56:12 +0000 (UTC) Received: from [10.10.116.23] (ovpn-116-23.rdu2.redhat.com [10.10.116.23]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0FFuBfQ007491 for ; Fri, 15 Jan 2016 10:56:11 -0500 To: gcc-patches List From: Jason Merrill Subject: C++ PATCH for c++/69257 (ICE with incomplete deref and asm) Message-ID: <5699169B.6080700@redhat.com> Date: Fri, 15 Jan 2016 10:56:11 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In this testcase, the compiler fails to diagnose trying to use the value of an INDIRECT_REF of incomplete type. Since decay_conversion is modeling the lvalue->rvalue conversion here, that seems a logical place to complain. When making that change, I noticed that we were incorrectly calling mark_rvalue_use for the array->pointer and function->pointer conversions, which are more properly considered lvalue uses, so I've fixed that as well. The convert_like_real change was necessary to retain the "initializing argument" message for several tests in the testsuite, since we're now diagnosing the use of incomplete in a different place. I've also improved the incomplete type diagnostic to use the location of the expression, if one is provided. Tested x86_64-pc-linux-gnu, applying to trunk. commit 0c5ad1f445e3008dcd25b6b6ac6f4cee7efce513 Author: Jason Merrill Date: Thu Jan 14 13:00:25 2016 -0500 * typeck2.c (cxx_incomplete_type_diagnostic): Use the location of value. diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index c67d7f6..ac2f3c3 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -475,13 +475,15 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, retry: /* We must print an error message. Be clever about what it says. */ + location_t loc = EXPR_LOC_OR_LOC (value, input_location); + switch (TREE_CODE (type)) { case RECORD_TYPE: case UNION_TYPE: case ENUMERAL_TYPE: if (!is_decl) - complained = emit_diagnostic (diag_kind, input_location, 0, + complained = emit_diagnostic (diag_kind, loc, 0, "invalid use of incomplete type %q#T", type); if (complained) @@ -489,7 +491,7 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, break; case VOID_TYPE: - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of %qT", type); break; @@ -499,7 +501,7 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, type = TREE_TYPE (type); goto retry; } - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of array with unspecified bounds"); break; @@ -511,11 +513,11 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, member = get_first_fn (member); if (DECL_FUNCTION_MEMBER_P (member) && ! flag_ms_extensions) - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of member function %qD " "(did you forget the %<()%> ?)", member); else - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of member %qD " "(did you forget the %<&%> ?)", member); } @@ -523,28 +525,28 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, case TEMPLATE_TYPE_PARM: if (is_auto (type)) - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of %"); else - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of template type parameter %qT", type); break; case BOUND_TEMPLATE_TEMPLATE_PARM: - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of template template parameter %qT", TYPE_NAME (type)); break; case TYPENAME_TYPE: - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of dependent type %qT", type); break; case LANG_TYPE: if (type == init_list_type_node) { - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "invalid use of brace-enclosed initializer list"); break; } @@ -552,14 +554,14 @@ cxx_incomplete_type_diagnostic (const_tree value, const_tree type, if (value && TREE_CODE (value) == COMPONENT_REF) goto bad_member; else if (value && TREE_CODE (value) == ADDR_EXPR) - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "address of overloaded function with no contextual " "type information"); else if (value && TREE_CODE (value) == OVERLOAD) - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "overloaded function with no contextual type information"); else - emit_diagnostic (diag_kind, input_location, 0, + emit_diagnostic (diag_kind, loc, 0, "insufficient contextual information to determine type"); break;