aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorRoger Sayle <sayle@gcc.gnu.org>2002-05-27 21:09:38 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2002-05-27 21:09:38 +0000
commit39f2f3c85a1e9999e3f38bfb5b9bbd35b062df67 (patch)
treeef5638bc097170d139e365da78c3dceb1d3a2ffa /gcc/c-common.c
parentd51b0053f5c1dd2509c69729d3c474b2cf7de66c (diff)
downloadgcc-39f2f3c85a1e9999e3f38bfb5b9bbd35b062df67.zip
gcc-39f2f3c85a1e9999e3f38bfb5b9bbd35b062df67.tar.gz
gcc-39f2f3c85a1e9999e3f38bfb5b9bbd35b062df67.tar.bz2
c-common.c: Add support for __attribute__((nothrow)) to specify that a function cannot...
* c-common.c: Add support for __attribute__((nothrow)) to specify that a function cannot throw an exception (using TREE_NOTHROW). (handle_nothrow_attribute): New function to process this attribute. * doc/extend.texi: Document the new nothrow function attribute. 2002-05-27 Richard Henderson <rth@redhat.com> * g++.dg/ext/attrib6.C: New test case. From-SVN: r53940
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 6086b02..aeb6a2e 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -351,6 +351,8 @@ static tree handle_vector_size_attribute PARAMS ((tree *, tree, tree, int,
bool *));
static tree handle_nonnull_attribute PARAMS ((tree *, tree, tree, int,
bool *));
+static tree handle_nothrow_attribute PARAMS ((tree *, tree, tree, int,
+ bool *));
static tree vector_size_helper PARAMS ((tree, tree));
static void check_function_nonnull PARAMS ((tree, tree));
@@ -425,6 +427,8 @@ const struct attribute_spec c_common_attribute_table[] =
handle_visibility_attribute },
{ "nonnull", 0, -1, false, true, true,
handle_nonnull_attribute },
+ { "nothrow", 0, 0, true, false, false,
+ handle_nothrow_attribute },
{ NULL, 0, 0, false, false, false, NULL }
};
@@ -5795,6 +5799,29 @@ get_nonnull_operand (arg_num_expr, valp)
*valp = TREE_INT_CST_LOW (arg_num_expr);
return true;
}
+
+/* Handle a "nothrow" attribute; arguments as in
+ struct attribute_spec.handler. */
+
+static tree
+handle_nothrow_attribute (node, name, args, flags, no_add_attrs)
+ tree *node;
+ tree name;
+ tree args ATTRIBUTE_UNUSED;
+ int flags ATTRIBUTE_UNUSED;
+ bool *no_add_attrs;
+{
+ if (TREE_CODE (*node) == FUNCTION_DECL)
+ TREE_NOTHROW (*node) = 1;
+ /* ??? TODO: Support types. */
+ else
+ {
+ warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
+ *no_add_attrs = true;
+ }
+
+ return NULL_TREE;
+}
/* Check for valid arguments being passed to a function. */
void