summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-04 16:18:03 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2010-10-04 16:18:03 +0000
commit5abb9721049b4ec8dae176238db943b668b2b1a5 (patch)
tree6429f24e6b3354b7521366525354ec246d6aef34 /gcc
parent7f719f690a1d5d5275273799677468d1ef1218e9 (diff)
downloadgcc-5abb9721049b4ec8dae176238db943b668b2b1a5.tar.gz
* tree.c (decl_storage_duration): New.
* cp-tree.h: Declare it. (duration_kind): Return values. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164944 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/cp-tree.h8
-rw-r--r--gcc/cp/tree.c19
3 files changed, 33 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index c5c40f8bee0..5ca247b3290 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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...
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6ce10e6af2c..fa625701f0e 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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) \
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index ddfb3542acf..174500ef66f 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