Check returned type is valid before using it.

Add a .isNull() check to returned QualType.  Fixes PR38077

llvm-svn: 336475
This commit is contained in:
Richard Trieu 2018-07-07 00:17:25 +00:00
parent 9664ca9dce
commit 0282655f9d
2 changed files with 11 additions and 0 deletions

View File

@ -846,6 +846,9 @@ bool Sema::ActOnCXXNestedNameSpecifierDecltype(CXXScopeSpec &SS,
assert(DS.getTypeSpecType() == DeclSpec::TST_decltype);
QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc());
if (T.isNull())
return true;
if (!T->isDependentType() && !T->getAs<TagType>()) {
Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace)
<< T << getLangOpts().CPlusPlus;

View File

@ -28,3 +28,11 @@ namespace rdar9623945 {
}
};
}
namespace PR38077 {
template <class T> void bar() {} // expected-note {{possible target for call}}
int run() {
decltype(bar)::does_not_exist; // expected-error {{reference to overloaded function could not be resolved; did you mean to call it?}}
}
}