if (Record[Idx++]) {
AttrVec Attrs;
Reader.ReadAttributes(F, Attrs, Record, Idx);
- D->setAttrsImpl(Attrs, Reader.getContext());
+ // If the declaration already has attributes, we assume that some other
+ // AST file already loaded them.
+ if (!D->hasAttrs())
+ D->setAttrsImpl(Attrs, Reader.getContext());
}
break;
}
inline int *getStaticDataMemberLeft() {
return WithUndefinedStaticDataMember<int[]>::undefined;
}
+
+inline WithAttributes<int> make_with_attributes_left() { return WithAttributes<int>(); }
inline int *getStaticDataMemberRight() {
return WithUndefinedStaticDataMember<int[]>::undefined;
}
+
+inline WithAttributes<int> make_with_attributes_right() { return WithAttributes<int>(); }
template<typename T> struct WithUndefinedStaticDataMember {
static T undefined;
};
+
+template<typename T> struct __attribute__((packed, aligned(2))) WithAttributes {
+ T value;
+};
+WithAttributes<int> *get_with_attributes();
(void) getStaticDataMemberRight();
}
-
+void testWithAttributes() {
+ auto a = make_with_attributes_left();
+ auto b = make_with_attributes_right();
+ static_assert(alignof(decltype(a)) == 2, "");
+ static_assert(alignof(decltype(b)) == 2, "");
+}