0ffeb6ec02
don't undefine C99 math macros, if !_GLIBCPP_USE_C99, so that we can use these functions in C++. espie@ agrees
121 lines
4.0 KiB
Plaintext
121 lines
4.0 KiB
Plaintext
$OpenBSD: patch-gcc_c-common_c,v 1.2 2008/07/25 20:50:26 martynas Exp $
|
|
--- gcc/c-common.c.orig Sun Jun 8 01:13:24 2003
|
|
+++ gcc/c-common.c Fri Jul 25 12:34:56 2008
|
|
@@ -39,7 +39,6 @@ Software Foundation, 59 Temple Place - Suite 330, Bost
|
|
#include "langhooks.h"
|
|
#include "except.h" /* For USING_SJLJ_EXCEPTIONS. */
|
|
#include "tree-inline.h"
|
|
-#include "c-tree.h"
|
|
|
|
cpp_reader *parse_in; /* Declared in c-pragma.h. */
|
|
|
|
@@ -333,7 +332,10 @@ int warn_format_nonliteral;
|
|
|
|
int warn_format_security;
|
|
|
|
+/* Warn about buffer size mismatches. */
|
|
|
|
+int warn_bounded;
|
|
+
|
|
/* C/ObjC language option variables. */
|
|
|
|
|
|
@@ -767,6 +769,8 @@ static tree handle_vector_size_attribute PARAMS ((tree
|
|
bool *));
|
|
static tree handle_nonnull_attribute PARAMS ((tree *, tree, tree, int,
|
|
bool *));
|
|
+static tree handle_sentinel_attribute PARAMS ((tree *, tree, tree, int,
|
|
+ bool *));
|
|
static tree handle_nothrow_attribute PARAMS ((tree *, tree, tree, int,
|
|
bool *));
|
|
static tree handle_cleanup_attribute PARAMS ((tree *, tree, tree, int,
|
|
@@ -850,12 +854,16 @@ const struct attribute_spec c_common_attribute_table[]
|
|
handle_deprecated_attribute },
|
|
{ "vector_size", 1, 1, false, true, false,
|
|
handle_vector_size_attribute },
|
|
+ { "bounded", 3, 4, false, true, false,
|
|
+ handle_bounded_attribute },
|
|
{ "visibility", 1, 1, true, false, false,
|
|
handle_visibility_attribute },
|
|
{ "tls_model", 1, 1, true, false, false,
|
|
handle_tls_model_attribute },
|
|
{ "nonnull", 0, -1, false, true, true,
|
|
handle_nonnull_attribute },
|
|
+ { "sentinel", 0, 0, false, true, true,
|
|
+ handle_sentinel_attribute },
|
|
{ "nothrow", 0, 0, true, false, false,
|
|
handle_nothrow_attribute },
|
|
{ "may_alias", 0, 0, false, true, false, NULL },
|
|
@@ -3052,6 +3060,7 @@ c_sizeof_or_alignof_type (type, op, complain)
|
|
const char *op_name;
|
|
tree value = NULL;
|
|
enum tree_code type_code = TREE_CODE (type);
|
|
+ bool sizeof_ptr_flag = false;
|
|
|
|
my_friendly_assert (op == SIZEOF_EXPR || op == ALIGNOF_EXPR, 20020720);
|
|
op_name = op == SIZEOF_EXPR ? "sizeof" : "__alignof__";
|
|
@@ -3083,10 +3092,15 @@ c_sizeof_or_alignof_type (type, op, complain)
|
|
else
|
|
{
|
|
if (op == SIZEOF_EXPR)
|
|
- /* Convert in case a char is more than one unit. */
|
|
- value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
|
|
- size_int (TYPE_PRECISION (char_type_node)
|
|
- / BITS_PER_UNIT));
|
|
+ {
|
|
+ /* Convert in case a char is more than one unit. */
|
|
+ value = size_binop (CEIL_DIV_EXPR, TYPE_SIZE_UNIT (type),
|
|
+ size_int (TYPE_PRECISION (char_type_node)
|
|
+ / BITS_PER_UNIT));
|
|
+
|
|
+ if (type_code == POINTER_TYPE)
|
|
+ sizeof_ptr_flag = true;
|
|
+ }
|
|
else
|
|
value = size_int (TYPE_ALIGN (type) / BITS_PER_UNIT);
|
|
}
|
|
@@ -3097,7 +3111,10 @@ c_sizeof_or_alignof_type (type, op, complain)
|
|
`size_t', which is just a typedef for an ordinary integer type. */
|
|
value = fold (build1 (NOP_EXPR, size_type_node, value));
|
|
my_friendly_assert (!TYPE_IS_SIZETYPE (TREE_TYPE (value)), 20001021);
|
|
-
|
|
+
|
|
+ if (sizeof_ptr_flag)
|
|
+ SIZEOF_PTR_DERIVED (value) = 1;
|
|
+
|
|
return value;
|
|
}
|
|
|
|
@@ -6381,6 +6398,21 @@ vector_size_helper (type, bottom)
|
|
return outer;
|
|
}
|
|
|
|
+/* Handle a "sentinel" attribute.
|
|
+ Just a stub for now. */
|
|
+
|
|
+static tree
|
|
+handle_sentinel_attribute (node, name, args, flags, no_add_attrs)
|
|
+ tree *node;
|
|
+ tree name ATTRIBUTE_UNUSED;
|
|
+ tree args;
|
|
+ int flags ATTRIBUTE_UNUSED;
|
|
+ bool *no_add_attrs;
|
|
+{
|
|
+ *no_add_attrs = true;
|
|
+ return NULL_TREE;
|
|
+}
|
|
+
|
|
/* Handle the "nonnull" attribute. */
|
|
static tree
|
|
handle_nonnull_attribute (node, name, args, flags, no_add_attrs)
|
|
@@ -6594,6 +6626,9 @@ check_function_arguments (attrs, params)
|
|
|
|
if (warn_format)
|
|
check_function_format (NULL, attrs, params);
|
|
+
|
|
+ if (warn_bounded)
|
|
+ check_function_bounded (NULL, attrs, params);
|
|
}
|
|
|
|
/* Generic argument checking recursion routine. PARAM is the argument to
|