[PATCH] clang-cl: Don't warn for unused private fields when encountering a late parsed template member

Ehsan Akhgari ehsan.akhgari at gmail.com
Fri Oct 10 13:48:13 PDT 2014


================
Comment at: lib/Sema/Sema.cpp:548
@@ -547,2 +547,3 @@
     else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
-      Complete = F->getTemplatedDecl()->isDefined();
+      Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
+                  F->getTemplatedDecl()->isDefined();
----------------
hans wrote:
> Is the issue that the template has been defined, but we haven't parsed and semantically analysed it because it's late-parsed?
> 
> This gets called from ActOnEndOfTranslationUnit, so shouldn't the delayed template parsing already have taken place?
Yes the template is not defined by we haven't done semantic analysis (and parsing!) on it yet.  It looks like by ActOnEndOfTranslationUnit the semantic analysis still wouldn't happen unless if we see a call to that function (or presumably other things such as its address being taken etc.)  IOW if the test case includes an instantiation of the template member, the warning doesn't appear.

http://reviews.llvm.org/D5718






More information about the cfe-commits mailing list