Skip to content
This repository was archived by the owner on Jun 20, 2019. It is now read-only.

Commit b030191

Browse files
committed
Handle pragma(inline) attributes.
1 parent 28b42cf commit b030191

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

gcc/d/ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
(build_closure): Don't set chain field for functions without context
2525
pointer.
2626

27+
2018-01-21 Iain Buclaw <[email protected]>
28+
29+
* decls.cc (get_symbol_decl): Handle pragma(inline) attributes.
30+
2731
2018-01-21 Iain Buclaw <[email protected]>
2832

2933
* decl.cc (DeclVisitor::visit(StructDeclaration)): Mark compiler

gcc/d/decl.cc

+20-2
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,16 @@ get_symbol_decl (Declaration *decl)
11311131
d_keep (newfntype);
11321132
}
11331133

1134-
/* Miscellaneous function flags. */
1135-
if (fd->isMember2 () || fd->isFuncLiteralDeclaration ())
1134+
/* In [pragma/inline], The attribute pragma(inline) affects whether a
1135+
function should be inlined or not. */
1136+
if (fd->inlining == PINLINEnever)
1137+
DECL_UNINLINABLE (decl->csym) = 1;
1138+
else if (fd->inlining == PINLINEalways)
1139+
{
1140+
DECL_DECLARED_INLINE_P (decl->csym) = 1;
1141+
DECL_DISREGARD_INLINE_LIMITS (decl->csym) = 1;
1142+
}
1143+
else if (fd->isMember2 () || fd->isFuncLiteralDeclaration ())
11361144
{
11371145
/* See grokmethod in cp/decl.c. Maybe we shouldn't be setting inline
11381146
flags without reason or proper handling. */
@@ -1240,6 +1248,16 @@ get_symbol_decl (Declaration *decl)
12401248
else
12411249
DECL_EXTERNAL (decl->csym) = 1;
12421250
}
1251+
1252+
/* Don't keep functions declared pragma(inline, true) unless
1253+
the user wants us to keep all inline functions. */
1254+
if (fd && fd->inlining == PINLINEalways && TREE_PUBLIC (decl->csym))
1255+
{
1256+
if (flag_keep_inline_functions)
1257+
mark_needed (decl->csym);
1258+
1259+
d_comdat_linkage (decl->csym) = 1;
1260+
}
12431261
}
12441262

12451263
/* Symbol is going in thread local storage. */

0 commit comments

Comments
 (0)