DeclContext *Owner;
const MultiLevelTemplateArgumentList &TemplateArgs;
+ void InstantiateAttrs(Decl *Tmpl, Decl *New);
+
public:
typedef Sema::OwningExprResult OwningExprResult;
};
}
+// FIXME: Is this too simple?
+void TemplateDeclInstantiator::InstantiateAttrs(Decl *Tmpl, Decl *New) {
+ for (const Attr *TmplAttr = Tmpl->getAttrs(); TmplAttr;
+ TmplAttr = TmplAttr->getNext()) {
+
+ // FIXME: Is cloning correct for all attributes?
+ Attr *NewAttr = TmplAttr->clone(SemaRef.Context);
+
+ New->addAttr(NewAttr);
+ }
+}
+
Decl *
TemplateDeclInstantiator::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
assert(false && "Translation units cannot be instantiated");
return 0;
}
+ InstantiateAttrs(D, Field);
+
if (Invalid)
Field->setInvalidDecl();
--- /dev/null
+// RUN: clang-cc -fsyntax-only -verify %s
+template <typename T>
+struct A {
+ char a __attribute__((aligned(16)));
+};
+int a[sizeof(A<int>) == 16 ? 1 : -1];
+