+2016-08-09 Jason Merrill <jason@redhat.com>
+
+ * c-common.c (c_common_attribute_table): vector_size affects type
+ identity.
+
2016-08-09 Marek Polacek <polacek@redhat.com>
PR c/7652
{ "deprecated", 0, 1, false, false, false,
handle_deprecated_attribute, false },
{ "vector_size", 1, 1, false, true, false,
- handle_vector_size_attribute, false },
+ handle_vector_size_attribute, true },
{ "visibility", 1, 1, false, false, false,
handle_visibility_attribute, false },
{ "tls_model", 1, 1, true, false, false,
2016-08-09 Jason Merrill <jason@redhat.com>
+ PR c++/68703
+ * decl2.c (any_dependent_type_attributes_p): New.
+ * pt.c (dependent_type_p_r, type_dependent_expression_p): Check it.
+ * semantics.c (finish_id_expression): Check it.
+ * typeck.c (finish_class_member_access_expr): Check it.
+
PR c++/71712
* class.c (check_abi_tags): Don't duplicate tags for conversion ops.
tree, bool, tree, tree);
extern tree grokbitfield (const cp_declarator *, cp_decl_specifier_seq *,
tree, tree);
+extern bool any_dependent_type_attributes_p (tree);
extern tree cp_reconstruct_complex_type (tree, tree);
extern bool attributes_naming_typedef_ok (tree);
extern void cplus_decl_attributes (tree *, tree, int);
}
}
+/* True if ATTRS contains any dependent attributes that affect type
+ identity. */
+
+bool
+any_dependent_type_attributes_p (tree attrs)
+{
+ for (tree a = attrs; a; a = TREE_CHAIN (a))
+ if (ATTR_IS_DEPENDENT (a))
+ {
+ const attribute_spec *as = lookup_attribute_spec (TREE_PURPOSE (a));
+ if (as && as->affects_type_identity)
+ return true;
+ }
+ return false;
+}
+
/* Return true iff ATTRS are acceptable attributes to be applied in-place
to a typedef which gives a previously unnamed class or enum a name for
linkage purposes. */
if (TREE_CODE (type) == TYPE_PACK_EXPANSION)
return true;
+ if (any_dependent_type_attributes_p (TYPE_ATTRIBUTES (type)))
+ return true;
+
/* The standard does not specifically mention types that are local
to template functions or local classes, but they should be
considered dependent too. For example:
gcc_assert (TREE_CODE (expression) != TYPE_DECL);
+ /* Dependent type attributes might not have made it from the decl to
+ the type yet. */
+ if (DECL_P (expression)
+ && any_dependent_type_attributes_p (DECL_ATTRIBUTES (expression)))
+ return true;
+
return (dependent_type_p (TREE_TYPE (expression)));
}
resolve the name at instantiation time. */
if (dependent_p)
{
+ if (DECL_P (decl)
+ && any_dependent_type_attributes_p (DECL_ATTRIBUTES (decl)))
+ /* Dependent type attributes on the decl mean that the TREE_TYPE is
+ wrong, so just return the identifier. */
+ return id_expression;
+
/* If we found a variable, then name lookup during the
instantiation will always resolve to the same VAR_DECL
(or an instantiation thereof). */
}
if (member == error_mark_node)
return error_mark_node;
+ if (DECL_P (member)
+ && any_dependent_type_attributes_p (DECL_ATTRIBUTES (member)))
+ /* Dependent type attributes on the decl mean that the TREE_TYPE is
+ wrong, so don't use it. */
+ goto dependent;
if (TREE_CODE (member) == USING_DECL && DECL_DEPENDENT_P (member))
goto dependent;
}
--- /dev/null
+// PR c++/68703
+
+template <int N>
+struct D {
+ int v __attribute__((vector_size (N * sizeof (int))));
+ int f1 () { return this->v[N-1]; }
+ int f2 () { return v[N-1]; }
+};
+
+int
+main ()
+{
+ D<4> a = { { 0, 1, 2, 3 } };
+ D<8> b = { { 0, 1, 2, 3, 4, 5, 6, 7 } };
+ if (a.f1 () != 3 || a.f2 () != 3
+ || b.f1 () != 7 || b.f2 () != 7)
+ __builtin_abort ();
+}
--- /dev/null
+// PR c++/68703
+
+template <int N>
+struct D {
+ int v __attribute__((vector_size (N * sizeof (int))));
+ int f1 () { return this->v[N-1]; }
+ int f2 () { return v[N-1]; }
+};
+
+int
+main ()
+{
+ D<4> a = { { 0, 1, 2, 3 } };
+ D<8> b = { { 0, 1, 2, 3, 4, 5, 6, 7 } };
+ if (a.f1 () != 3 || a.f2 () != 3
+ || b.f1 () != 7 || b.f2 () != 7)
+ __builtin_abort ();
+}