Lines 82-87
Link Here
|
82 |
static void write_out_vars (tree); |
82 |
static void write_out_vars (tree); |
83 |
static void import_export_class (tree); |
83 |
static void import_export_class (tree); |
84 |
static tree get_guard_bits (tree); |
84 |
static tree get_guard_bits (tree); |
|
|
85 |
static void determine_visibility_from_class (tree, tree); |
85 |
|
86 |
|
86 |
/* A list of static class variables. This is needed, because a |
87 |
/* A list of static class variables. This is needed, because a |
87 |
static class variable can be declared inside the class without |
88 |
static class variable can be declared inside the class without |
Lines 1578-1590
Link Here
|
1578 |
} |
1579 |
} |
1579 |
|
1580 |
|
1580 |
/* Like c_determine_visibility, but with additional C++-specific |
1581 |
/* Like c_determine_visibility, but with additional C++-specific |
1581 |
behavior. */ |
1582 |
behavior. |
1582 |
|
1583 |
|
|
|
1584 |
Function-scope entities can rely on the function's visibility because |
1585 |
it is set in start_preparsed_function. |
1586 |
|
1587 |
Class-scope entities cannot rely on the class's visibility until the end |
1588 |
of the enclosing class definition. |
1589 |
|
1590 |
Note that because namespaces have multiple independent definitions, |
1591 |
namespace visibility is handled elsewhere using the #pragma visibility |
1592 |
machinery rather than by decorating the namespace declaration. */ |
1593 |
|
1583 |
void |
1594 |
void |
1584 |
determine_visibility (tree decl) |
1595 |
determine_visibility (tree decl) |
1585 |
{ |
1596 |
{ |
1586 |
tree class_type; |
1597 |
tree class_type; |
1587 |
|
1598 |
|
|
|
1599 |
/* Only relevant for names with external linkage. */ |
1600 |
if (!TREE_PUBLIC (decl)) |
1601 |
return; |
1602 |
|
1588 |
/* Cloned constructors and destructors get the same visibility as |
1603 |
/* Cloned constructors and destructors get the same visibility as |
1589 |
the underlying function. That should be set up in |
1604 |
the underlying function. That should be set up in |
1590 |
maybe_clone_body. */ |
1605 |
maybe_clone_body. */ |
Lines 1608-1613
Link Here
|
1608 |
so they are automatically handled above. */ |
1623 |
so they are automatically handled above. */ |
1609 |
gcc_assert (TREE_CODE (decl) != VAR_DECL |
1624 |
gcc_assert (TREE_CODE (decl) != VAR_DECL |
1610 |
|| !DECL_VTABLE_OR_VTT_P (decl)); |
1625 |
|| !DECL_VTABLE_OR_VTT_P (decl)); |
|
|
1626 |
|
1627 |
if (DECL_FUNCTION_SCOPE_P (decl)) |
1628 |
{ |
1629 |
tree fn = DECL_CONTEXT (decl); |
1630 |
DECL_VISIBILITY (decl) = DECL_VISIBILITY (fn); |
1631 |
DECL_VISIBILITY_SPECIFIED (decl) = DECL_VISIBILITY_SPECIFIED (fn); |
1632 |
} |
1633 |
|
1611 |
/* Entities not associated with any class just get the |
1634 |
/* Entities not associated with any class just get the |
1612 |
visibility specified by their attributes. */ |
1635 |
visibility specified by their attributes. */ |
1613 |
return; |
1636 |
return; |
Lines 1617-1650
Link Here
|
1617 |
the visibility of their containing class. */ |
1640 |
the visibility of their containing class. */ |
1618 |
if (class_type) |
1641 |
if (class_type) |
1619 |
{ |
1642 |
{ |
1620 |
if (TARGET_DLLIMPORT_DECL_ATTRIBUTES |
1643 |
determine_visibility_from_class (decl, class_type); |
1621 |
&& lookup_attribute ("dllexport", TYPE_ATTRIBUTES (class_type))) |
1644 |
|
|
|
1645 |
/* Give the target a chance to override the visibility associated |
1646 |
with DECL. */ |
1647 |
if (TREE_CODE (decl) == VAR_DECL |
1648 |
&& (DECL_TINFO_P (decl) |
1649 |
|| (DECL_VTABLE_OR_VTT_P (decl) |
1650 |
/* Construction virtual tables are not exported because |
1651 |
they cannot be referred to from other object files; |
1652 |
their name is not standardized by the ABI. */ |
1653 |
&& !DECL_CONSTRUCTION_VTABLE_P (decl))) |
1654 |
&& TREE_PUBLIC (decl) |
1655 |
&& !DECL_REALLY_EXTERN (decl) |
1656 |
&& DECL_VISIBILITY_SPECIFIED (decl) |
1657 |
&& (!class_type || !CLASSTYPE_VISIBILITY_SPECIFIED (class_type))) |
1658 |
targetm.cxx.determine_class_data_visibility (decl); |
1659 |
} |
1660 |
} |
1661 |
|
1662 |
static void |
1663 |
determine_visibility_from_class (tree decl, tree class_type) |
1664 |
{ |
1665 |
if (TARGET_DLLIMPORT_DECL_ATTRIBUTES |
1666 |
&& lookup_attribute ("dllexport", TYPE_ATTRIBUTES (class_type))) |
1667 |
{ |
1668 |
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT; |
1669 |
DECL_VISIBILITY_SPECIFIED (decl) = 1; |
1670 |
} |
1671 |
else if (TREE_CODE (decl) == FUNCTION_DECL |
1672 |
&& DECL_DECLARED_INLINE_P (decl) |
1673 |
&& visibility_options.inlines_hidden) |
1674 |
{ |
1675 |
/* Don't change it if it has been set explicitly by user. */ |
1676 |
if (!DECL_VISIBILITY_SPECIFIED (decl)) |
1622 |
{ |
1677 |
{ |
1623 |
DECL_VISIBILITY (decl) = VISIBILITY_DEFAULT; |
1678 |
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; |
1624 |
DECL_VISIBILITY_SPECIFIED (decl) = 1; |
1679 |
DECL_VISIBILITY_SPECIFIED (decl) = 1; |
1625 |
} |
1680 |
} |
1626 |
else if (TREE_CODE (decl) == FUNCTION_DECL |
|
|
1627 |
&& DECL_DECLARED_INLINE_P (decl) |
1628 |
&& visibility_options.inlines_hidden) |
1629 |
{ |
1630 |
/* Don't change it if it has been set explicitly by user. */ |
1631 |
if (!DECL_VISIBILITY_SPECIFIED (decl)) |
1632 |
{ |
1633 |
DECL_VISIBILITY (decl) = VISIBILITY_HIDDEN; |
1634 |
DECL_VISIBILITY_SPECIFIED (decl) = 1; |
1635 |
} |
1636 |
} |
1637 |
else if (CLASSTYPE_VISIBILITY_SPECIFIED (class_type)) |
1638 |
{ |
1639 |
DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type); |
1640 |
DECL_VISIBILITY_SPECIFIED (decl) = 1; |
1641 |
} |
1642 |
else if (!DECL_VISIBILITY_SPECIFIED (decl)) |
1643 |
{ |
1644 |
DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type); |
1645 |
DECL_VISIBILITY_SPECIFIED (decl) = 0; |
1646 |
} |
1647 |
} |
1681 |
} |
|
|
1682 |
else if (CLASSTYPE_VISIBILITY_SPECIFIED (class_type)) |
1683 |
{ |
1684 |
DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type); |
1685 |
DECL_VISIBILITY_SPECIFIED (decl) = 1; |
1686 |
} |
1687 |
else if (TYPE_CLASS_SCOPE_P (class_type)) |
1688 |
determine_visibility_from_class (decl, TYPE_CONTEXT (class_type)); |
1689 |
else if (TYPE_FUNCTION_SCOPE_P (class_type)) |
1690 |
{ |
1691 |
tree fn = TYPE_CONTEXT (class_type); |
1692 |
DECL_VISIBILITY (decl) = DECL_VISIBILITY (fn); |
1693 |
DECL_VISIBILITY_SPECIFIED (decl) = DECL_VISIBILITY_SPECIFIED (fn); |
1694 |
} |
1695 |
else if (!DECL_VISIBILITY_SPECIFIED (decl)) |
1696 |
{ |
1697 |
DECL_VISIBILITY (decl) = CLASSTYPE_VISIBILITY (class_type); |
1698 |
DECL_VISIBILITY_SPECIFIED (decl) = 0; |
1699 |
} |
1648 |
} |
1700 |
} |
1649 |
|
1701 |
|
1650 |
/* DECL is a FUNCTION_DECL or VAR_DECL. If the object file linkage |
1702 |
/* DECL is a FUNCTION_DECL or VAR_DECL. If the object file linkage |
Lines 1911-1931
Link Here
|
1911 |
comdat_linkage (decl); |
1963 |
comdat_linkage (decl); |
1912 |
} |
1964 |
} |
1913 |
|
1965 |
|
1914 |
/* Give the target a chance to override the visibility associated |
|
|
1915 |
with DECL. */ |
1916 |
if (TREE_CODE (decl) == VAR_DECL |
1917 |
&& (DECL_TINFO_P (decl) |
1918 |
|| (DECL_VTABLE_OR_VTT_P (decl) |
1919 |
/* Construction virtual tables are not exported because |
1920 |
they cannot be referred to from other object files; |
1921 |
their name is not standardized by the ABI. */ |
1922 |
&& !DECL_CONSTRUCTION_VTABLE_P (decl))) |
1923 |
&& TREE_PUBLIC (decl) |
1924 |
&& !DECL_REALLY_EXTERN (decl) |
1925 |
&& DECL_VISIBILITY_SPECIFIED (decl) |
1926 |
&& (!class_type || !CLASSTYPE_VISIBILITY_SPECIFIED (class_type))) |
1927 |
targetm.cxx.determine_class_data_visibility (decl); |
1928 |
|
1929 |
DECL_INTERFACE_KNOWN (decl) = 1; |
1966 |
DECL_INTERFACE_KNOWN (decl) = 1; |
1930 |
} |
1967 |
} |
1931 |
|
1968 |
|