From patchwork Wed Oct 4 12:50:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 821299 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-463449-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="HIxvm6Xh"; 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 3y6bNp6tGsz9t2S for ; Wed, 4 Oct 2017 23:50:50 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=tZ5WDSSYgZGykniT/b6gVyyUYv3QlXTe6Di3ara3D5nZ8XCWEB 6MVno2Id9Naf4OvLwY4H3f+Q5OJ6fXqHx0tk296PSeEeAKDzAzqDgNqIWXXD3xB0 7v1UGCPzzphJxxhQ3heoUOdEQvtj4sXbOq+87eL/scKCmW1LUkbbTvCQ0= 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:cc :from:subject:message-id:date:mime-version:content-type; s= default; bh=yTX1bNB6cauyUJJtdMluiEiwoS0=; b=HIxvm6Xhi0V7Eq9T4M9h ajChquxF+NeRGR0tbw5GjtJ6m5fkxA2lwzmKi9zjJJUMHd75VwbJ6TLI3+MhYVgU NGbYBzoRpv0wclLtlscoeDE3PQxsv6xI9MaXBV4j9rLfQEM37yGjFkxCwfadn7Lo ZfiTqCrDWF/Ib/2C22Xeel0= Received: (qmail 57044 invoked by alias); 4 Oct 2017 12:50:41 -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 57028 invoked by uid 89); 4 Oct 2017 12:50:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:ip*192.168.1.4, Hx-spam-relays-external:192.168.1.4, H*RU:192.168.1.4 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 ESMTP; Wed, 04 Oct 2017 12:50:39 +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 v94CoZTs014598 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Oct 2017 12:50:36 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v94CoZtO006526 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Oct 2017 12:50:35 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v94CoZxg015381; Wed, 4 Oct 2017 12:50:35 GMT Received: from [192.168.1.4] (/95.235.10.222) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Oct 2017 05:50:34 -0700 To: "gcc-patches@gcc.gnu.org" Cc: Nathan Sidwell From: Paolo Carlini Subject: [C++ Patch] PR 71946 ("asm in toplevel lambda function rejected") Message-ID: Date: Wed, 4 Oct 2017 14:50:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 X-IsSubscribed: yes Hi, Andrew noticed that the reason we reject entities like inline-asm or GNU's statement-expressions in the lambda body is simply that we don't set the parser->in_function_body flag. Thus the below, which appears to work perfectly for that. Tested x86_64-linux. Thanks, Paolo. /////////////////// /cp 2017-10-04 Paolo Carlini Andrew Pinski PR c++/71946 * parser.c (cp_parser_lambda_body): Set parser->in_function_body. /testsuite 2017-10-04 Paolo Carlini Andrew Pinski PR c++/71946 * g++.dg/cpp0x/lambda/lambda-asm1.C: New. * g++.dg/cpp0x/lambda/lambda-stmtexpr1.C: Likewise. Index: cp/parser.c =================================================================== --- cp/parser.c (revision 253398) +++ cp/parser.c (working copy) @@ -10557,6 +10557,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lam { bool nested = (current_function_decl != NULL_TREE); bool local_variables_forbidden_p = parser->local_variables_forbidden_p; + bool in_function_body = parser->in_function_body; if (nested) push_function_context (); else @@ -10567,6 +10568,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lam save_omp_privatization_clauses (omp_privatization_save); /* Clear this in case we're in the middle of a default argument. */ parser->local_variables_forbidden_p = false; + parser->in_function_body = true; /* Finish the function call operator - class_specifier @@ -10653,6 +10655,7 @@ cp_parser_lambda_body (cp_parser* parser, tree lam restore_omp_privatization_clauses (omp_privatization_save); parser->local_variables_forbidden_p = local_variables_forbidden_p; + parser->in_function_body = in_function_body; if (nested) pop_function_context(); else Index: testsuite/g++.dg/cpp0x/lambda/lambda-asm1.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-asm1.C (revision 0) +++ testsuite/g++.dg/cpp0x/lambda/lambda-asm1.C (working copy) @@ -0,0 +1,4 @@ +// PR c++/71946 +// { dg-do compile { target c++11 } } + +auto test = []{ __asm__ __volatile__ ("" : : "r" (0) ); }; Index: testsuite/g++.dg/cpp0x/lambda/lambda-stmtexpr1.C =================================================================== --- testsuite/g++.dg/cpp0x/lambda/lambda-stmtexpr1.C (revision 0) +++ testsuite/g++.dg/cpp0x/lambda/lambda-stmtexpr1.C (working copy) @@ -0,0 +1,5 @@ +// PR c++/71946 +// { dg-do compile { target c++11 } } +// { dg-options "" } + +auto test = []{ int t = ({ int t1; t1 = 7; t1; }); };