http://llvm.org/bugs/show_bug.cgi?id=10272

           Summary: attribute in method in template class doesn't survive
                    instantiation
           Product: clang
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected], [email protected]


Given:

template <class Ty> struct Vector  {
  void growStorageBy();
};
template <class T> __attribute__((noinline)) void Vector<T>::growStorageBy() {
}
void foo() {
 Vector<int> strs;
 strs.growStorageBy();
}

clang produces:

define linkonce_odr void @_ZN6VectorIiE13growStorageByEv(%struct.Vector* %this)
nounwind align 2 {

Note that the noinline is missing.

Adding

  for (DeclContext::decl_iterator I = Tmpl->getDeclContext()->decls_begin(),
         E = Tmpl->getDeclContext()->decls_end(); I != E; ++I) {
    Decl *D = *I;
    for (AttrVec::const_iterator i = D->attr_begin(), e = D->attr_end();
         i != e; ++i) {
      const Attr *TmplAttr = *i;
      if (TmplAttr->getKind() == clang::attr::NoInline) {
        assert(0 && "foo");
      }
    }
  }

to Sema::InstantiateAttrs hits the assert, so the attribute is available in a
redeclaration. Now, I don't know if the attribute should have been merged at
this point or if Sema::InstantiateAttrs should walk redeclations.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to