[PATCH] D48506: Fix for Crash in nested name specifier decltype

Balaji Iyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 22 14:46:36 PDT 2018


bviyer created this revision.
bviyer added reviewers: rsmith, arphaman.

There was a crash when qualtype is null in the function Sema::ActOnCXXNestedNameSpecifierDecltype. If it is null then just return without processing it further.


Repository:
  rC Clang

https://reviews.llvm.org/D48506

Files:
  lib/Sema/SemaCXXScopeSpec.cpp
  test/SemaCXX/qualtype-null-check.cpp


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);
+};
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<TagType>()) {
     Diag(DS.getTypeSpecTypeLoc(), diag::err_expected_class_or_namespace) 
       << T << getLangOpts().CPlusPlus;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48506.152544.patch
Type: text/x-patch
Size: 951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180622/031c202f/attachment.bin>


More information about the cfe-commits mailing list