v.g.vassilev planned changes to this revision.
v.g.vassilev added inline comments.


================
Comment at: clang/test/SemaCXX/warn-func-not-needed.cpp:13
 namespace test1_template {
-template <typename T> static void f() {}
+template <typename T> static void f() {} // expected-warning {{unused function 
template}}
 template <> void f<int>() {} // expected-warning {{function 'f<int>' is not 
needed and will not be emitted}}
----------------
ldionne wrote:
> aaron.ballman wrote:
> > v.g.vassilev wrote:
> > > aaron.ballman wrote:
> > > > v.g.vassilev wrote:
> > > > > aaron.ballman wrote:
> > > > > > Why is this unused? `f<long>()` in `foo()` should cause this to be 
> > > > > > used, right?
> > > > > > 
> > > > > > How should a user silence this diagnostic without disabling it 
> > > > > > entirely?
> > > > > Nobody uses `foo`.
> > > > Ah, good point on `foo` not being used, but the question still stands 
> > > > -- how does the user silence this diagnostic? It's not at all uncommon 
> > > > to have a primary template with specializations where the TU only uses 
> > > > either the primary or a specialization, but not both (and certainly not 
> > > > all specializations).
> > > @philnik used `[[maybe_unused]]` which seemed reasonable to me for 
> > > silencing the diagnostic. Maybe take a look at the changes done here: 
> > > https://reviews.llvm.org/D144667
> > That's reasonable if the interface is one the user controls, such as one 
> > within a .cpp file. But the situation I'm worried about is where the 
> > primary template and specializations live in a header file that's shared 
> > between multiple TUs. I don't think it's reasonable to expect users to put 
> > `[[maybe_unused]]` on the primary template and all specializations in that 
> > situation.
> Don't y'all find it weird to have to use `[[maybe_unused]]` on something that 
> is only a declaration like those CTAD guides? And I agree with @aaron.ballman 
> here: we provide headers that are used in various TUs, and we obviously never 
> expect that the entirety of our headers is going to be used by every single 
> TU.
> 
> In other words, we totally expect that those deduction guides will be unused 
> in some cases, since it's entirely fine for a user not to use them but for us 
> to still provide them. If I understood this correctly, this seems like a flaw 
> in the warning that we should fix in Clang.
Yes, I agree I am pretty sure we can fix the CTAD guides. I just need a few 
spare cycles...


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143524/new/

https://reviews.llvm.org/D143524

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to