From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23708 invoked by alias); 27 May 2011 08:52:11 -0000 Received: (qmail 23691 invoked by uid 22791); 27 May 2011 08:52:09 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from smtp205.alice.it (HELO smtp205.alice.it) (82.57.200.101) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 May 2011 08:51:53 +0000 Received: from [192.168.1.4] (79.36.197.165) by smtp205.alice.it (8.5.124.08) id 4DCBB263016EB7EA; Fri, 27 May 2011 10:51:48 +0200 Message-ID: <4DDF664A.9060509@oracle.com> Date: Fri, 27 May 2011 12:04:00 -0000 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 MIME-Version: 1.0 To: Jason Merrill CC: "gcc-patches@gcc.gnu.org" Subject: Re: [C++ Patch] PR 42056 References: <4DDE9C50.7050601@oracle.com> <4DDF2095.3020300@redhat.com> In-Reply-To: <4DDF2095.3020300@redhat.com> Content-Type: multipart/mixed; boundary="------------020205090700000600000700" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-05/txt/msg02141.txt.bz2 This is a multi-part message in MIME format. --------------020205090700000600000700 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1050 Hi, > On 05/26/2011 02:30 PM, Paolo Carlini wrote: >> We want to do that only when processing a template, because otherwise we >> get a duplicate diagnostic, see, eg, auto9.C > Hmm, where's the error coming from in the non-template case? From > cp_build_c_cast? In that case always giving the error in > build_functional_cast and then returning error_mark_node should avoid > duplication. I should have told you. The error is produced via complete_type_or_maybe_complain called from line 1650 of build_functional_cast itself, by cxx_incomplete_type_diagnostic. >> error_mark_node unconditionally, means a better diagnostic, without >> redundant "array bound is not an integer constant before...". > I'd rather deal with that by suppressing that error if we already have > error_mark_node. complete_type_or_maybe_complain, when type is an error_mark_node understands that an error has been produced already and simply returns NULL_TREE. Thus, something like the below works. Is it closer to what you had in mind? Paolo. ///////////////// --------------020205090700000600000700 Content-Type: text/plain; name="CL_42056_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="CL_42056_2" Content-length: 355 /cp 2011-05-27 Paolo Carlini PR c++/42056 * typeck2.c (build_functional_cast): Complain early for invalid uses of 'auto' and set type to error_mark_node. /testsuite 2011-05-27 Paolo Carlini PR c++/42056 * testsuite/g++.dg/cpp0x/auto25.C: New. * testsuite/g++.dg/cpp0x/auto26.C: Likewise. --------------020205090700000600000700 Content-Type: text/plain; name="patch_42056_2" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch_42056_2" Content-length: 1177 Index: testsuite/g++.dg/cpp0x/auto25.C =================================================================== --- testsuite/g++.dg/cpp0x/auto25.C (revision 0) +++ testsuite/g++.dg/cpp0x/auto25.C (revision 0) @@ -0,0 +1,7 @@ +// PR c++/42056 +// { dg-options -std=c++0x } + +template struct A +{ + int a[auto(1)]; // { dg-error "invalid use of" } +}; Index: testsuite/g++.dg/cpp0x/auto26.C =================================================================== --- testsuite/g++.dg/cpp0x/auto26.C (revision 0) +++ testsuite/g++.dg/cpp0x/auto26.C (revision 0) @@ -0,0 +1,7 @@ +// PR c++/42056 +// { dg-options -std=c++0x } + +template void foo() +{ + int a[auto(1)]; // { dg-error "invalid use of" } +} Index: cp/typeck2.c =================================================================== --- cp/typeck2.c (revision 174321) +++ cp/typeck2.c (working copy) @@ -1599,6 +1599,13 @@ build_functional_cast (tree exp, tree parms, tsubs return error_mark_node; } + if (type_uses_auto (type)) + { + if (complain & tf_error) + error ("invalid use of %"); + type = error_mark_node; + } + if (processing_template_decl) { tree t; --------------020205090700000600000700--