aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/tree.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2010-10-04 12:18:03 -0400
committerJason Merrill <jason@gcc.gnu.org>2010-10-04 12:18:03 -0400
commitb95ca5135eb61adb45e38d837808418ed9334b88 (patch)
tree6429f24e6b3354b7521366525354ec246d6aef34 /gcc/cp/tree.c
parent828fde809c0a0c1e64a411f3db10c02d775a9f3d (diff)
downloadgcc-b95ca5135eb61adb45e38d837808418ed9334b88.zip
gcc-b95ca5135eb61adb45e38d837808418ed9334b88.tar.gz
gcc-b95ca5135eb61adb45e38d837808418ed9334b88.tar.bz2
tree.c (decl_storage_duration): New.
* tree.c (decl_storage_duration): New. * cp-tree.h: Declare it. (duration_kind): Return values. From-SVN: r164944
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r--gcc/cp/tree.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index ddfb354..174500e 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2985,6 +2985,25 @@ decl_linkage (tree decl)
/* Everything else has internal linkage. */
return lk_internal;
}
+
+/* Returns the storage duration of the object or reference associated with
+ the indicated DECL, which should be a VAR_DECL or PARM_DECL. */
+
+duration_kind
+decl_storage_duration (tree decl)
+{
+ if (TREE_CODE (decl) == PARM_DECL)
+ return dk_auto;
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ return dk_static;
+ gcc_assert (TREE_CODE (decl) == VAR_DECL);
+ if (!TREE_STATIC (decl)
+ && !DECL_EXTERNAL (decl))
+ return dk_auto;
+ if (DECL_THREAD_LOCAL_P (decl))
+ return dk_thread;
+ return dk_static;
+}
/* EXP is an expression that we want to pre-evaluate. Returns (in
*INITP) an expression that will perform the pre-evaluation. The