r336475 - Check returned type is valid before using it.

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 6 17:17:25 PDT 2018


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?}}
+  }
+}




More information about the cfe-commits mailing list