diff options
author | Mark Mitchell <mark@codesourcery.com> | 2000-10-31 01:30:59 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2000-10-31 01:30:59 +0000 |
commit | ad50e811dc95387b52dddd7ab753db59512a3baf (patch) | |
tree | 62873128afbebb3b4075750f0c2dbc4160b90b4b /gcc/cp/tree.c | |
parent | 4bc950092b4a22757f6893f53c1d1ad8fd85381b (diff) | |
download | gcc-ad50e811dc95387b52dddd7ab753db59512a3baf.zip gcc-ad50e811dc95387b52dddd7ab753db59512a3baf.tar.gz gcc-ad50e811dc95387b52dddd7ab753db59512a3baf.tar.bz2 |
cp-tree.h (DECL_EXTERNAL_LINKAGE_P): New macro.
* cp-tree.h (DECL_EXTERNAL_LINKAGE_P): New macro.
(linkage_kind): New enumeration.
(decl_linkage): New function.
* decl2.c (comdat_linkage): Extend comment.
* error.c (dump_function_decl): Print the arguments used to
instantiate a template, even when not printing the type of the
function.
* pt.c (convert_nontype_argument): Use DECL_EXTERNAL_LINKAGE_P,
not TREE_PUBLIC, to test for external linkage.
* tree.c (decl_linkage): New function.
From-SVN: r37150
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r-- | gcc/cp/tree.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d6314d8..db5e33d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2597,3 +2597,46 @@ char_type_p (type) || same_type_p (type, signed_char_type_node) || same_type_p (type, wchar_type_node)); } + +/* Returns the kind of linkage associated with the indicated DECL. Th + value returned is as specified by the language standard; it is + independent of implementation details regarding template + instantiation, etc. For example, it is possible that a declaration + to which this function assigns external linkage would not show up + as a global symbol when you run `nm' on the resulting object file. */ + +linkage_kind +decl_linkage (decl) + tree decl; +{ + /* This function doesn't attempt to calculate the linkage from first + principles as given in [basic.link]. Instead, it makes use of + the fact that we have already set TREE_PUBLIC appropriately, and + then handles a few special cases. Ideally, we would calculate + linkage first, and then transform that into a concrete + implementation. */ + + /* Things that don't have names have no linkage. */ + if (!DECL_NAME (decl)) + return lk_none; + + /* Things that are TREE_PUBLIC have external linkage. */ + if (TREE_PUBLIC (decl)) + return lk_external; + + /* Some things that are not TREE_PUBLIC have external linkage, too. + For example, on targets that don't have weak symbols, we make all + template instantiations have internal linkage (in the object + file), but the symbols should still be treated as having external + linkage from the point of view of the language. */ + if (DECL_LANG_SPECIFIC (decl) && DECL_COMDAT (decl)) + return lk_external; + + /* Things in local scope do not have linkage, if they don't have + TREE_PUBLIC set. */ + if (decl_function_context (decl)) + return lk_none; + + /* Everything else has internal linkage. */ + return lk_internal; +} |