Index: lib/Sema/SemaCXXScopeSpec.cpp =================================================================== --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -846,6 +846,8 @@ assert(DS.getTypeSpecType() == DeclSpec::TST_decltype); QualType T = BuildDecltypeType(DS.getRepAsExpr(), DS.getTypeSpecTypeLoc()); + if (T.getTypePtrOrNull() == nullptr) + return true; if (!T->isDependentType() && !T->getAs()) { Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace) << T << getLangOpts().CPlusPlus; Index: test/SemaCXX/qualtype-null-check.cpp =================================================================== --- /dev/null +++ test/SemaCXX/qualtype-null-check.cpp @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify %s +struct A +{ + bool x{&decltype(foo)::foo}; // expected-error {{reference to non-static member function must be called}} + void foo(int); +};