From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14901 invoked by alias); 26 May 2011 18:30:28 -0000 Received: (qmail 14886 invoked by uid 22791); 26 May 2011 18:30:26 -0000 X-SWARE-Spam-Status: No, hits=-1.8 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; Thu, 26 May 2011 18:30:07 +0000 Received: from [192.168.1.4] (79.53.14.183) by smtp205.alice.it (8.5.124.08) id 4DCBB2630163F899; Thu, 26 May 2011 20:30:04 +0200 Message-ID: <4DDE9C50.7050601@oracle.com> Date: Thu, 26 May 2011 19:38: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: "gcc-patches@gcc.gnu.org" CC: Jason Merrill Subject: [C++ Patch] PR 42056 Content-Type: multipart/mixed; boundary="------------050408030803000109080307" 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/msg02091.txt.bz2 This is a multi-part message in MIME format. --------------050408030803000109080307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 555 Hi, I have just regtested on x86_64-linux the below patchlet for a simple accepts-invalid, exploiting type_uses_auto, as suggested by Jason. We want to do that only when processing a template, because otherwise we get a duplicate diagnostic, see, eg, auto9.C; also, not returning error_mark_node unconditionally, means a better diagnostic, without redundant "array bound is not an integer constant before...". As for the error message itself, I'm just emitting what we otherwise emit outside templates... Ok? Thanks, Paolo. /////////////////// --------------050408030803000109080307 Content-Type: text/plain; name="CL_42056" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="CL_42056" Content-length: 345 /cp 2011-05-26 Paolo Carlini PR c++/42056 * typeck2.c (build_functional_cast): When processing_template_decl, check for invalid uses of 'auto'. /testsuite 2011-05-26 Paolo Carlini PR c++/42056 * testsuite/g++.dg/cpp0x/auto25.C: New. * testsuite/g++.dg/cpp0x/auto26.C: Likewise. --------------050408030803000109080307 Content-Type: text/plain; name="patch_42056" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="patch_42056" Content-length: 1266 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 174301) +++ cp/typeck2.c (working copy) @@ -1603,6 +1603,14 @@ build_functional_cast (tree exp, tree parms, tsubs { tree t; + if (type_uses_auto (type)) + { + if (complain & tf_error) + error ("invalid use of %"); + else + return error_mark_node; + } + /* Diagnose this even in a template. We could also try harder to give all the usual errors when the type and args are non-dependent... */ --------------050408030803000109080307--