When instantiating a field decl, make sure to clone its attributes. With this change FileCheck no longer crashes when it's run without any arguments.

llvm-svn: 86344
This commit is contained in:
Anders Carlsson 2009-11-07 06:07:58 +00:00
parent 975a119f31
commit 3d70975917
2 changed files with 23 additions and 0 deletions

View File

@ -28,6 +28,8 @@ namespace {
DeclContext *Owner;
const MultiLevelTemplateArgumentList &TemplateArgs;
void InstantiateAttrs(Decl *Tmpl, Decl *New);
public:
typedef Sema::OwningExprResult OwningExprResult;
@ -89,6 +91,18 @@ namespace {
};
}
// 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");
@ -258,6 +272,8 @@ Decl *TemplateDeclInstantiator::VisitFieldDecl(FieldDecl *D) {
return 0;
}
InstantiateAttrs(D, Field);
if (Invalid)
Field->setInvalidDecl();

View File

@ -0,0 +1,7 @@
// 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];