summaryrefslogtreecommitdiff
path: root/gcc/c-family/c-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-family/c-common.c')
-rw-r--r--gcc/c-family/c-common.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 48561828532..34273fbcb10 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -10188,6 +10188,13 @@ sync_resolve_size (tree function, vec<tree, va_gc> *params)
}
type = TREE_TYPE ((*params)[0]);
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* Force array-to-pointer decay for C++. */
+ gcc_assert (c_dialect_cxx());
+ (*params)[0] = default_conversion ((*params)[0]);
+ type = TREE_TYPE ((*params)[0]);
+ }
if (TREE_CODE (type) != POINTER_TYPE)
goto incompatible;
@@ -10339,6 +10346,13 @@ get_atomic_generic_size (location_t loc, tree function,
/* Get type of first parameter, and determine its size. */
type_0 = TREE_TYPE ((*params)[0]);
+ if (TREE_CODE (type_0) == ARRAY_TYPE)
+ {
+ /* Force array-to-pointer decay for C++. */
+ gcc_assert (c_dialect_cxx());
+ (*params)[0] = default_conversion ((*params)[0]);
+ type_0 = TREE_TYPE ((*params)[0]);
+ }
if (TREE_CODE (type_0) != POINTER_TYPE || VOID_TYPE_P (TREE_TYPE (type_0)))
{
error_at (loc, "argument 1 of %qE must be a non-void pointer type",
@@ -11756,8 +11770,21 @@ convert_vector_to_pointer_for_subscript (location_t loc,
c_common_mark_addressable_vec (*vecp);
type = build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type));
- type = build_pointer_type (type);
type1 = build_pointer_type (TREE_TYPE (*vecp));
+ bool ref_all = TYPE_REF_CAN_ALIAS_ALL (type1);
+ if (!ref_all
+ && !DECL_P (*vecp))
+ {
+ /* If the original vector isn't declared may_alias and it
+ isn't a bare vector look if the subscripting would
+ alias the vector we subscript, and if not, force ref-all. */
+ alias_set_type vecset = get_alias_set (*vecp);
+ alias_set_type sset = get_alias_set (type);
+ if (!alias_sets_must_conflict_p (sset, vecset)
+ && !alias_set_subset_of (sset, vecset))
+ ref_all = true;
+ }
+ type = build_pointer_type_for_mode (type, ptr_mode, ref_all);
*vecp = build1 (ADDR_EXPR, type1, *vecp);
*vecp = convert (type, *vecp);
}