From: Nathan Sidwell Date: Mon, 19 Mar 2018 18:56:22 +0000 (+0000) Subject: [PR c++/84835] ICE with generic lambda in extern "C" X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=143f00e1126c474e7caceba74747e3173b16e87c;p=gcc.git [PR c++/84835] ICE with generic lambda in extern "C" https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00890.html 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. From-SVN: r258655 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 66226033e41..12aaf135294 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 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++/84812 * name-lookup.c (set_local_extern_decl_linkage): Defend against ambiguous lookups. diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c index b3c75c84682..374060626c1 100644 --- a/gcc/cp/lambda.c +++ b/gcc/cp/lambda.c @@ -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); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 745c9acd6ee..fba65b4abdf 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2202df759b9..2bc81cabd63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-19 Nathan Sidwell + + PR c++/84835 + * g++.dg/cpp1y/pr84835.C: New. + 2018-03-19 Sudakshina Das PR target/81647 diff --git a/gcc/testsuite/g++.dg/cpp1y/pr84835.C b/gcc/testsuite/g++.dg/cpp1y/pr84835.C new file mode 100644 index 00000000000..8dca3e949f2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/pr84835.C @@ -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" } }