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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 2 05:43:50 PDT 2015


On Fri, Oct 2, 2015 at 1:26 AM, Keno Fischer
<kfischer at college.harvard.edu> wrote:
> 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:

Ah shoot, that's right. I hadn't noticed  [dcl.attr.grammar]p4.
Specifically, the strangely easily-understandable sentence: No
attribute-specifier-seq shall appertain to an explicit instantiation.

Sorry about that!

~Aaron

>
> ```
> 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