]> gcc.gnu.org Git - gcc.git/commitdiff
tree.c (decl_storage_duration): New.
authorJason Merrill <jason@redhat.com>
Mon, 4 Oct 2010 16:18:03 +0000 (12:18 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 4 Oct 2010 16:18:03 +0000 (12:18 -0400)
* tree.c (decl_storage_duration): New.
* cp-tree.h: Declare it.
(duration_kind): Return values.

From-SVN: r164944

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/tree.c

index c5c40f8bee028c09697eb69c725b93be8da3e959..5ca247b329026fee17bf70ddf0468302189a5b47 100644 (file)
@@ -1,3 +1,9 @@
+2010-10-04  Jason Merrill  <jason@redhat.com>
+
+       * tree.c (decl_storage_duration): New.
+       * cp-tree.h: Declare it.
+       (duration_kind): Return values.
+
 2010-10-03  Jason Merrill  <jason@redhat.com>
 
        * typeck.c (require_complete_type_sfinae): Add complain parm to...
index 6ce10e6af2cacb6ffe5bca96db48a93750c8aeec..fa625701f0e17b775e00ac64c68909d7361a9367 100644 (file)
@@ -3934,6 +3934,13 @@ typedef enum linkage_kind {
   lk_external                  /* External linkage.  */
 } linkage_kind;
 
+typedef enum duration_kind {
+  dk_static,
+  dk_thread,
+  dk_auto,
+  dk_dynamic
+} duration_kind;
+
 /* Bitmask flags to control type substitution.  */
 enum tsubst_flags {
   tf_none = 0,                  /* nothing special */
@@ -5402,6 +5409,7 @@ extern int count_trees                            (tree);
 extern int char_type_p                         (tree);
 extern void verify_stmt_tree                   (tree);
 extern linkage_kind decl_linkage               (tree);
+extern duration_kind decl_storage_duration     (tree);
 extern tree cp_walk_subtrees (tree*, int*, walk_tree_fn,
                              void*, struct pointer_set_t*);
 #define cp_walk_tree(a,b,c,d) \
index ddfb3542acffe49d01665c763a15b2bf5f70af3b..174500ef66f3b74672eee4a454276c56c23ce5b5 100644 (file)
@@ -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;
+}
 \f
 /* EXP is an expression that we want to pre-evaluate.  Returns (in
    *INITP) an expression that will perform the pre-evaluation.  The
This page took 0.089269 seconds and 5 git commands to generate.