Check returned type is valid before using it.
authorRichard Trieu <rtrieu@google.com>
Sat, 7 Jul 2018 00:17:25 +0000 (00:17 +0000)
committerRichard Trieu <rtrieu@google.com>
Sat, 7 Jul 2018 00:17:25 +0000 (00:17 +0000)
Add a .isNull() check to returned QualType.  Fixes PR38077

llvm-svn: 336475

clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/test/SemaCXX/overloaded-name.cpp

index 61a82aa..f2fad82 100644 (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;
index 6da0354..8f1dc2f 100644 (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?}}
+  }
+}