forked from OSchip/llvm-project
clang-cl: Don't warn for unused private fields when encountering a late parsed template member
Summary: This fixes PR21235. Test Plan: Includes an automated test. Reviewers: hansw Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5718 llvm-svn: 219551
This commit is contained in:
parent
6666c27e99
commit
4b5ca9a222
|
@ -545,7 +545,12 @@ static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD,
|
||||||
if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
|
if (const CXXMethodDecl *M = dyn_cast<CXXMethodDecl>(*I))
|
||||||
Complete = M->isDefined() || (M->isPure() && !isa<CXXDestructorDecl>(M));
|
Complete = M->isDefined() || (M->isPure() && !isa<CXXDestructorDecl>(M));
|
||||||
else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
|
else if (const FunctionTemplateDecl *F = dyn_cast<FunctionTemplateDecl>(*I))
|
||||||
Complete = F->getTemplatedDecl()->isDefined();
|
// If the template function is marked as late template parsed at this point,
|
||||||
|
// it has not been instantiated and therefore we have not performed semantic
|
||||||
|
// analysis on it yet, so we cannot know if the type can be considered
|
||||||
|
// complete.
|
||||||
|
Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
|
||||||
|
F->getTemplatedDecl()->isDefined();
|
||||||
else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
|
else if (const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
|
||||||
if (R->isInjectedClassName())
|
if (R->isInjectedClassName())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
// RUN: %clang_cc1 -fsyntax-only -fdelayed-template-parsing -Wunused-private-field -Wused-but-marked-unused -Wno-uninitialized -verify -std=c++11 %s
|
||||||
|
// expected-no-diagnostics
|
||||||
|
|
||||||
|
class EverythingMayBeUsed {
|
||||||
|
int x;
|
||||||
|
public:
|
||||||
|
template <class T>
|
||||||
|
void f() {
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue