aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2012-11-14 21:08:52 +0000
committerJan Hubicka <jh@suse.cz>2012-11-14 21:08:52 +0000
commitdf11a5064fa023960678bc5e592140b68076bad2 (patch)
tree5fb8b989add99f1d1897d54cb4463dcbfc40b2ca /gcc/tree.c
parent70f78c7fda2c92c34353845c6dd88c8e0c9c0780 (diff)
* tree.c (set_call_expr_flags): New function.
(local_define_builtin): Use it. * tree.h (set_call_expr_flags): Declare. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@193506 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 16dc5df03aa..cb8b81c659c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -9541,6 +9541,39 @@ build_common_tree_nodes (bool signed_char, bool short_double)
}
}
+/* Modify DECL for given flags. */
+void
+set_call_expr_flags (tree decl, int flags)
+{
+ if (flags & ECF_NOTHROW)
+ TREE_NOTHROW (decl) = 1;
+ if (flags & ECF_CONST)
+ TREE_READONLY (decl) = 1;
+ if (flags & ECF_PURE)
+ DECL_PURE_P (decl) = 1;
+ if (flags & ECF_LOOPING_CONST_OR_PURE)
+ DECL_LOOPING_CONST_OR_PURE_P (decl) = 1;
+ if (flags & ECF_NOVOPS)
+ DECL_IS_NOVOPS (decl) = 1;
+ if (flags & ECF_NORETURN)
+ TREE_THIS_VOLATILE (decl) = 1;
+ if (flags & ECF_MALLOC)
+ DECL_IS_MALLOC (decl) = 1;
+ if (flags & ECF_RETURNS_TWICE)
+ DECL_IS_RETURNS_TWICE (decl) = 1;
+ if (flags & ECF_LEAF)
+ DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"),
+ NULL, DECL_ATTRIBUTES (decl));
+ if ((flags & ECF_TM_PURE) && flag_tm)
+ DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("transaction_pure"),
+ NULL, DECL_ATTRIBUTES (decl));
+ /* Looping const or pure is implied by noreturn.
+ There is currently no way to declare looping const or looping pure alone. */
+ gcc_assert (!(flags & ECF_LOOPING_CONST_OR_PURE)
+ || ((flags & ECF_NORETURN) && (flags & (ECF_CONST | ECF_PURE))));
+}
+
+
/* A subroutine of build_common_builtin_nodes. Define a builtin function. */
static void
@@ -9551,23 +9584,7 @@ local_define_builtin (const char *name, tree type, enum built_in_function code,
decl = add_builtin_function (name, type, code, BUILT_IN_NORMAL,
library_name, NULL_TREE);
- if (ecf_flags & ECF_CONST)
- TREE_READONLY (decl) = 1;
- if (ecf_flags & ECF_PURE)
- DECL_PURE_P (decl) = 1;
- if (ecf_flags & ECF_LOOPING_CONST_OR_PURE)
- DECL_LOOPING_CONST_OR_PURE_P (decl) = 1;
- if (ecf_flags & ECF_NORETURN)
- TREE_THIS_VOLATILE (decl) = 1;
- if (ecf_flags & ECF_NOTHROW)
- TREE_NOTHROW (decl) = 1;
- if (ecf_flags & ECF_MALLOC)
- DECL_IS_MALLOC (decl) = 1;
- if (ecf_flags & ECF_LEAF)
- DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("leaf"),
- NULL, DECL_ATTRIBUTES (decl));
- if ((ecf_flags & ECF_TM_PURE) && flag_tm)
- apply_tm_attr (decl, get_identifier ("transaction_pure"));
+ set_call_expr_flags (decl, ecf_flags);
set_builtin_decl (code, decl, true);
}