From patchwork Mon Mar 19 18:54:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 887839 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-474955-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="EI1QGyhi"; 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 404lcF0CLpz9sV9 for ; Tue, 20 Mar 2018 05:54:51 +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 :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=JN8CBssueosGcFVRAhU3ixcZW/2X57ZR17KvByrjR83Z7RucmE V5c7DuL0Sa7eeqhmliuzit9BSjkhh9VT3PyfLoxfd4SLTL8rpOrJK95Tdd/2Cbbw FkWdNjr8+2Ksmc+W5MxR+3WmHezFM0mZC9YRIitazkGgwRx/IxvGexRb0= 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=C7mp9sNPf3jUen3wzqWwKtutXNA=; b=EI1QGyhiX5+x1bm5bTEz NCAbvJyjMTXJU3BdpcS5Ymztc2zCydTD84zRsTAPeuF0YzbCdsBsBRUqyajLFuiJ j+DjtEMD3o0pHt1skIfMGpoB6h2/r2TY1B6mS0037LKBtgemy0YCbS3T8BYrezK4 09pD/3byNq+0rPlu7q8GE0I= Received: (qmail 104358 invoked by alias); 19 Mar 2018 18:54:44 -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 104348 invoked by uid 89); 19 Mar 2018 18:54:43 -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, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-yw0-f176.google.com Received: from mail-yw0-f176.google.com (HELO mail-yw0-f176.google.com) (209.85.161.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 19 Mar 2018 18:54:41 +0000 Received: by mail-yw0-f176.google.com with SMTP id z21so1002322ywg.11 for ; Mon, 19 Mar 2018 11:54:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=zTv6ckQCTdtlupamXZZdot8azThxhKsjsefRntB+T58=; b=OnBVPQ2Y7sdtRbj4TJRNe/QUqbJUSGL4+/0PRZZRSj9ipG5O2zdaiTiDgMQbG20SI3 zsrkIJ3BZSR0Cmqkkb7Qlq3vdpQhRb9BG1sxbQTllquxp5TLsbJoxGj2rgdbT5pgdCBb J5rZPCV3llPgEwPXUd8zaWNXO7kGe/XSJpqtLcAKXqGNBAfYljDIMQT7HUn13yNO3Lhn zLN0dpVZc+tf13/d3x5JCWTnjW80rqUeld3VxS3FPTGJC2N5pAhDCyLUyxeVVLR4La+q q29Y1HYU8o494lFXaUrz/coCUvdTdTVr/TWXPld8ti2DFUXx8Kp2LGgqgqev07clvhwo MQfQ== X-Gm-Message-State: AElRT7EHf1EqqUIrhUdZMoC2YlT8+JyxGTlAjFU/RPChbt/XcQF7VdYZ vKlZq7BvdZmYY3U6KivknQE= X-Google-Smtp-Source: AG47ELsF5x/bMiSA/MKdDal7lnHNOG7yZxwvCwxLo3dwAFUrNGrFEYtbN0bUix2+/PW9LOJW4pm94w== X-Received: by 10.129.103.193 with SMTP id b184mr3347933ywc.350.1521485675375; Mon, 19 Mar 2018 11:54:35 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::2:ec9e]) by smtp.googlemail.com with ESMTPSA id x187sm264890ywb.31.2018.03.19.11.54.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Mar 2018 11:54:34 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [PR c++/84835] ICE with generic lambda in extern "C" Message-ID: <19c432c2-63ae-216c-5514-2893e4bc3e85@acm.org> Date: Mon, 19 Mar 2018 14:54:32 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In an extern "C" region the lambda member fns were getting C linkage. and triggering an assert I added. I'm not sure why just the generic case was being triggered, but the fix is to just force the language to be C++ -- this is what we do in finish_member_declaration. We were also not copying the linkage into the template header. Mostly that was ok, because we then ignored it. But sometimes, like this, things went wrong. applying to trunk. nathan 2018-03-19 Nathan Sidwell PR c++/84835 * lambda.c (maybe_add_lambda_conv_op): Force C++ linkage. * pt.c (build_template_decl): Propagate language linkage. PR c++/84835 * g++.dg/cpp1y/pr84835.C: New. Index: cp/lambda.c =================================================================== --- cp/lambda.c (revision 258642) +++ cp/lambda.c (working copy) @@ -1176,6 +1176,7 @@ maybe_add_lambda_conv_op (tree type) tree thistype = cp_build_qualified_type (type, TYPE_QUAL_CONST); tree fntype = build_method_type_directly (thistype, rettype, void_list_node); tree convfn = build_lang_decl (FUNCTION_DECL, name, fntype); + SET_DECL_LANGUAGE (convfn, lang_cplusplus); tree fn = convfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); SET_DECL_ALIGN (fn, MINIMUM_METHOD_BOUNDARY); @@ -1208,6 +1209,7 @@ maybe_add_lambda_conv_op (tree type) name = get_identifier ("_FUN"); tree statfn = build_lang_decl (FUNCTION_DECL, name, stattype); + SET_DECL_LANGUAGE (statfn, lang_cplusplus); fn = statfn; DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); grokclassfn (type, fn, NO_SPECIAL); Index: cp/pt.c =================================================================== --- cp/pt.c (revision 258642) +++ cp/pt.c (working copy) @@ -4677,6 +4677,7 @@ tree build_template_decl (tree decl, tree parms, bool member_template_p) { tree tmpl = build_lang_decl (TEMPLATE_DECL, DECL_NAME (decl), NULL_TREE); + SET_DECL_LANGUAGE (tmpl, DECL_LANGUAGE (decl)); DECL_TEMPLATE_PARMS (tmpl) = parms; DECL_CONTEXT (tmpl) = DECL_CONTEXT (decl); DECL_SOURCE_LOCATION (tmpl) = DECL_SOURCE_LOCATION (decl); Index: testsuite/g++.dg/cpp1y/pr84835.C =================================================================== --- testsuite/g++.dg/cpp1y/pr84835.C (revision 0) +++ testsuite/g++.dg/cpp1y/pr84835.C (working copy) @@ -0,0 +1,20 @@ +// { dg-do compile { target c++14 } } +// PR c++/84835 +// ICE with generic lambda inside extern "C" + +extern "C" +{ + auto r = [] (auto x) + { + void baz (); // extern "C" + baz (); + }; + +} + +void g () +{ + r (0); +} + +// { dg-final { scan-assembler "\[^0-9\]baz" } }