[PATCH] D13330: Implement __attribute__((unique_instantiation))

Keno Fischer via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 1 22:26:26 PDT 2015


loladiro added inline comments.

================
Comment at: include/clang/Basic/Attr.td:1462
@@ +1461,3 @@
+def UniqueInstantiation : InheritableAttr {
+  let Spellings = [GCC<"unique_instantiation">];
+  let Subjects = SubjectList<[CXXRecord]>;
----------------
loladiro wrote:
> aaron.ballman wrote:
> > This is not a GCC attribute, so it should not be spelled as such. Since this only applies to C++ code, I would recommend a C++11 spelling (in the clang namespace). If you think this is something C++03 and earlier code would really benefit from, then you could also add a GNU-style spelling.
> No, this is C++11 only. Will change the spelling.
It doesn't appear like the grammar allows attributes to be specified on explicit template definitions. I'll change the spelling to GNU:

```
error:
      an attribute list cannot appear here
template struct foo<int> [[clang::unique_instantiation]];
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                [[clang::unique_instantiation]]
error:
      an attribute list cannot appear here
template struct [[clang::unique_instantiation]] foo<int>;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error:
      an attribute list cannot appear here
template [[clang::unique_instantiation]] struct foo<int>;
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error:
      an attribute list cannot appear here
[[clang::unique_instantiation]] template struct foo<int>;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
FileCheck error: '-' is empty.
```


Repository:
  rL LLVM

http://reviews.llvm.org/D13330





More information about the cfe-commits mailing list