diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index da0954b34..6bf352282 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -24,6 +24,10 @@ (build_closure): Don't set chain field for functions without context pointer. +2018-01-21 Iain Buclaw + + * decls.cc (get_symbol_decl): Handle pragma(inline) attributes. + 2018-01-21 Iain Buclaw * decl.cc (DeclVisitor::visit(StructDeclaration)): Mark compiler diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc index 88204923a..1bc579044 100644 --- a/gcc/d/decl.cc +++ b/gcc/d/decl.cc @@ -1131,8 +1131,16 @@ get_symbol_decl (Declaration *decl) d_keep (newfntype); } - /* Miscellaneous function flags. */ - if (fd->isMember2 () || fd->isFuncLiteralDeclaration ()) + /* In [pragma/inline], The attribute pragma(inline) affects whether a + function should be inlined or not. */ + if (fd->inlining == PINLINEnever) + DECL_UNINLINABLE (decl->csym) = 1; + else if (fd->inlining == PINLINEalways) + { + DECL_DECLARED_INLINE_P (decl->csym) = 1; + DECL_DISREGARD_INLINE_LIMITS (decl->csym) = 1; + } + else if (fd->isMember2 () || fd->isFuncLiteralDeclaration ()) { /* See grokmethod in cp/decl.c. Maybe we shouldn't be setting inline flags without reason or proper handling. */ @@ -1240,6 +1248,16 @@ get_symbol_decl (Declaration *decl) else DECL_EXTERNAL (decl->csym) = 1; } + + /* Don't keep functions declared pragma(inline, true) unless + the user wants us to keep all inline functions. */ + if (fd && fd->inlining == PINLINEalways && TREE_PUBLIC (decl->csym)) + { + if (flag_keep_inline_functions) + mark_needed (decl->csym); + + d_comdat_linkage (decl->csym); + } } /* Symbol is going in thread local storage. */