diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-15 20:07:15 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-15 20:07:15 +0000 |
commit | fa9bb8dc72e83d89b2aa40786661dda5b5f69856 (patch) | |
tree | 3f80a50c3fcfae96e4ad234c43d2c52fe02de202 /gcc/c-family | |
parent | 22623b9c398e31770e33cc73a23fce6b26b95f63 (diff) | |
download | gcc-fa9bb8dc72e83d89b2aa40786661dda5b5f69856.tar.gz |
2016-04-15 Basile Starynkevitch <basile@starynkevitch.net>
{{merging with even more of GCC 6, using subversion 1.9
svn merge -r230171:230180 ^/trunk
}}
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@235047 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/c-family/c-common.c | 22 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 1 | ||||
-rw-r--r-- | gcc/c-family/c-pragma.c | 6 |
4 files changed, 38 insertions, 3 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 0a99798d5fa..eb4d5bfbae2 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,15 @@ +2015-11-11 Marek Polacek <polacek@redhat.com> + + PR c/68107 + PR c++/68266 + * c-common.c (valid_array_size_p): New function. + * c-common.h (valid_array_size_p): Declare. + +2015-11-11 Dominique d'Humieres <dominiq@lps.ens.fr> + + PR bootstrap/68271 + * c-pragma.c (c_register_pragma_1): Update the gcc_assert to 256. + 2015-11-11 Andrew MacLeod <amacleod@redhat.com> * array-notation-common.c: Remove unused header files. diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 2b5071f6d23..9cf37ebfcd5 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -13107,4 +13107,26 @@ warn_duplicated_cond_add_or_warn (location_t loc, tree cond, vec<tree> **chain) (*chain)->safe_push (cond); } +/* Check if array size calculations overflow or if the array covers more + than half of the address space. Return true if the size of the array + is valid, false otherwise. TYPE is the type of the array and NAME is + the name of the array, or NULL_TREE for unnamed arrays. */ + +bool +valid_array_size_p (location_t loc, tree type, tree name) +{ + if (type != error_mark_node + && COMPLETE_TYPE_P (type) + && TREE_CODE (TYPE_SIZE_UNIT (type)) == INTEGER_CST + && !valid_constant_size_p (TYPE_SIZE_UNIT (type))) + { + if (name) + error_at (loc, "size of array %qE is too large", name); + else + error_at (loc, "size of unnamed array is too large"); + return false; + } + return true; +} + #include "gt-c-family-c-common.h" diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 8badc9b6ad6..d7fcf387588 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1464,5 +1464,6 @@ extern bool check_no_cilk (tree, const char *, const char *, location_t loc = UNKNOWN_LOCATION); extern bool reject_gcc_builtin (const_tree, location_t = UNKNOWN_LOCATION); extern void warn_duplicated_cond_add_or_warn (location_t, tree, vec<tree> **); +extern bool valid_array_size_p (location_t, tree, tree); #endif /* ! GCC_C_COMMON_H */ diff --git a/gcc/c-family/c-pragma.c b/gcc/c-family/c-pragma.c index c1bdf23f479..62755990376 100644 --- a/gcc/c-family/c-pragma.c +++ b/gcc/c-family/c-pragma.c @@ -1366,9 +1366,9 @@ c_register_pragma_1 (const char *space, const char *name, id = registered_pragmas.length (); id += PRAGMA_FIRST_EXTERNAL - 1; - /* The C++ front end allocates 6 bits in cp_token; the C front end - allocates 7 bits in c_token. At present this is sufficient. */ - gcc_assert (id < 64); + /* The C++ front end allocates 8 bits in cp_token; the C front end + allocates 8 bits in c_token. At present this is sufficient. */ + gcc_assert (id < 256); } cpp_register_deferred_pragma (parse_in, space, name, id, |