From patchwork Fri Aug 21 09:06:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 509426 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 E1560140772 for ; Fri, 21 Aug 2015 19:07:10 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=uyNXFVXp; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=GBmROcHvnbOYNEaI4 ICfgjeGSizNCMnjkS8xDp7JSmaxmXSbX0+QML/jajdYAhL+jnOmFni1SPJ016a4g 8O5q1ETgJUYlZVgSJI3otqBzB5brRxBD0b7if7sH7jqUfB40F1Tal/ye8DDOQ//W 3PXEAjYJaoSMUstfpKWYSbFHH8= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=sKkDSTOsNPF/8p3wxoFAGEU qJ/w=; b=uyNXFVXpR7NTmKvQ5xuQ4Ac6QWoNkTjXhRMGqPTePye14wIpo9HRMRI MEcWfxBxpDajXYz8QG1/0E8frnOkyaYcbhegke/V3pVX5bmTDZ2P6gZ+dbg/KXM6 +/BRcvCeQY/xixElNIGSSXX62fyzBycsE6e0+MbCju2EcA+WkbLM= Received: (qmail 45853 invoked by alias); 21 Aug 2015 09:07:00 -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 45839 invoked by uid 89); 21 Aug 2015 09:07:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: aserp1040.oracle.com Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 21 Aug 2015 09:06:59 +0000 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t7L96unn012775 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 21 Aug 2015 09:06:56 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t7L96tvr014817 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Fri, 21 Aug 2015 09:06:56 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t7L96tKe021152; Fri, 21 Aug 2015 09:06:55 GMT Received: from [192.168.1.4] (/79.37.218.190) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 21 Aug 2015 02:06:55 -0700 Subject: Re: [C++ Patch] PR 67065 ("Missing diagnostics for ill-formed program with main variable instead of function") To: Markus Trippelsdorf References: <55D4DD2D.3070500@oracle.com> <20150821061830.GB399@x4> <20150821063050.GC399@x4> <55D6E691.1000308@oracle.com> Cc: "gcc-patches@gcc.gnu.org" , Jason Merrill From: Paolo Carlini Message-ID: <55D6EA2C.2090400@oracle.com> Date: Fri, 21 Aug 2015 11:06:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55D6E691.1000308@oracle.com> X-IsSubscribed: yes ... I'm testing the below. So far appears to work well for me. Paolo. /////////////////// Index: cp/decl.c =================================================================== --- cp/decl.c (revision 227054) +++ cp/decl.c (working copy) @@ -8357,7 +8357,8 @@ grokvardecl (tree type, if (DECL_NAME (decl) && MAIN_NAME_P (DECL_NAME (decl)) - && CP_DECL_CONTEXT (decl) == global_namespace) + && CP_DECL_CONTEXT (decl) == global_namespace + && !at_function_scope_p ()) error ("cannot declare %<::main%> to be a global variable"); /* Check that the variable can be safely declared as a concept. Index: testsuite/g++.dg/other/pr67065.C =================================================================== --- testsuite/g++.dg/other/pr67065.C (revision 227054) +++ testsuite/g++.dg/other/pr67065.C (working copy) @@ -1,3 +1,5 @@ // PR c++/67065 int main; // { dg-error "cannot declare" } + +void foo() { int main; }