Don't look into incomplete types when trying to warn about unused

variables. Fixes PR6948.

llvm-svn: 102436
This commit is contained in:
Douglas Gregor 2010-04-27 16:20:13 +00:00
parent a9f7c3263e
commit 19defcd6f5
2 changed files with 13 additions and 0 deletions

View File

@ -543,6 +543,11 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D) {
return false;
}
// If we failed to complete the type for some reason, don't
// diagnose the variable.
if (Ty->isIncompleteType())
return false;
if (const TagType *TT = Ty->getAs<TagType>()) {
const TagDecl *Tag = TT->getDecl();
if (Tag->hasAttr<UnusedAttr>())

View File

@ -51,3 +51,11 @@ void test_dependent_init(T *p) {
X0<int> i(p);
(void)i;
}
namespace PR6948 {
template<typename T> class X;
void f() {
X<char> str (read_from_file()); // expected-error{{use of undeclared identifier 'read_from_file'}}
}
}