[PATCH] D13330: Implement __attribute__((unique_instantiation))
Keno Fischer via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 6 19:17:21 PST 2015
loladiro added inline comments.
================
Comment at: include/clang/Basic/Attr.td:1463
@@ +1462,3 @@
+ let Spellings = [GNU<"unique_instantiation">];
+ let Subjects = SubjectList<[Function, CXXRecord], ErrorDiag>;
+ let Documentation = [UniqueInstantiationDocs];
----------------
loladiro wrote:
> majnemer wrote:
> > They work ok, clang just thinks that it's a declaration of a variable template. Try this:
> > template <typename T> T n = T();
> > extern template int n<int>;
> > template int n<int>;
> I see. I'll look into adding support for it. Can you explain why my example doesn't work? GCC seems to allow this.
Bump on the question of differences to GCC here.
================
Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2456
@@ -2450,1 +2455,3 @@
+def err_unique_instantiation_not_previous : Error<
+ "'unique_instantiation' attribute must be specified for all declarations and definitions of this explicit template instantiation">;
----------------
aaron.ballman wrote:
> > They are checking for two different conditions in the spec. One requires that all explicit template instantiations with this attribute have a declaration, the other that every declaration/definition has the attribute.
>
> Okay, I see now what this diagnostic is attempting to convey. I think it should read:
> ```
> def err_unique_instantiation_no_declaration : Error<
> "'unique_instantiation' attribute on an explicit instantiation requires a previous explicit instantiation declaration">;
> ```
Sounds good.
================
Comment at: test/SemaCXX/unique-instantiations.cpp:23
@@ +22,2 @@
+extern template struct __attribute__((unique_instantiation)) foo5<int>; // expected-note{{previous explicit instantiation is here}}
+template struct foo5<int>; // expected-error{{must be specified for all declarations}}
----------------
aaron.ballman wrote:
> Missing tests for correct usage of the attribute. Missing tests of the attribute diagnosing when given arguments.
Isn't the correct usage checked for in the CodeGen tests above?
Repository:
rL LLVM
http://reviews.llvm.org/D13330
More information about the cfe-commits
mailing list