Thanks for the fix! Though maybe this isn't the best diagnostic experience - given that 'bar' isn't technically an overloaded function, but is a function template - worth doing something more precise here? (maybe not)
Wonder if there's similar handling for other diagnostic cases that could be used here (whether there's something that handles the equivalent: auto *f = &bar; situation with a better diagnostic & whether that infrastructure could be reused here) On Fri, Jul 6, 2018 at 5:22 PM Richard Trieu via cfe-commits < [email protected]> wrote: > Author: rtrieu > Date: Fri Jul 6 17:17:25 2018 > New Revision: 336475 > > URL: http://llvm.org/viewvc/llvm-project?rev=336475&view=rev > Log: > Check returned type is valid before using it. > > Add a .isNull() check to returned QualType. Fixes PR38077 > > Modified: > cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp > cfe/trunk/test/SemaCXX/overloaded-name.cpp > > Modified: cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp?rev=336475&r1=336474&r2=336475&view=diff > > ============================================================================== > --- cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp (original) > +++ cfe/trunk/lib/Sema/SemaCXXScopeSpec.cpp Fri Jul 6 17:17:25 2018 > @@ -846,6 +846,9 @@ bool Sema::ActOnCXXNestedNameSpecifierDe > 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; > > Modified: cfe/trunk/test/SemaCXX/overloaded-name.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-name.cpp?rev=336475&r1=336474&r2=336475&view=diff > > ============================================================================== > --- cfe/trunk/test/SemaCXX/overloaded-name.cpp (original) > +++ cfe/trunk/test/SemaCXX/overloaded-name.cpp Fri Jul 6 17:17:25 2018 > @@ -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?}} > + } > +} > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
