On Feb 26, 2013, at 8:39 AM, Rafael Espíndola <[email protected]> wrote: >> I found one more bug, with problem (1). It looks like the first >> declaration of a type must be marked visible, not just any declaration >> before an instantiation with that type: > > The problem comes from the template using the canonical (first) decl > for the arguments. Some extra examples: > > template <typename T> > struct __attribute__((visibility("default"))) barT { > static void zed() {} > }; > class foo; > class __attribute__((visibility("default"))) foo; > template struct barT<foo>; > > template <int* I> > struct __attribute__((visibility("default"))) barI { > static void zed() {} > }; > extern int I; > extern int I __attribute__((visibility("default"))); > template struct barI<&I>; > > typedef void (*fType)(void); > template<fType F> > struct __attribute__((visibility("default"))) barF { > static void zed() {} > }; > void F(); > void F() __attribute__((visibility("default")));; > template struct barF<F>; > > This is somewhat easy to hack in the visibility computation (see > attached patch), but what should we do for cases like: > > > template <typename T> > struct __attribute__((visibility("default"))) barT { > static void zed() {} > }; > class foo; > template struct barT<foo>; > class __attribute__((visibility("default"))) foo; > > > With this patch we print a hidden visibility. But for > > emplate <int* I> > struct __attribute__((visibility("default"))) barI { > static void zed() {} > }; > extern int I; > void use() { > barI<&I>::zed(); > } > extern int I __attribute__((visibility("default"))); > > We produce a default one unless the last line is commented. Should the > template instantiation point to the last decl available when it is > created?
In these cases, templates point to types, not declarations. But the declaration stored in the type is the first declaration until we see a definition, at which point it's always that. This patch seems fine. John. _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
