[PATCH] D110315: [Sema] Fix a null pointer reference crash.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 23 07:38:01 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3778c1cd6ef5: [Sema] Fix a null pointer reference crash. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D110315/new/

https://reviews.llvm.org/D110315

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/rounding-math-crash.cpp


Index: clang/test/SemaCXX/rounding-math-crash.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/rounding-math-crash.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -fsyntax-only -frounding-math -verify %s
+
+template <class b> b::a() {}  // expected-error {{nested name specifier}}
Index: clang/lib/Sema/SemaDecl.cpp
===================================================================
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -14493,7 +14493,7 @@
   FunctionScopeInfo *FSI = getCurFunction();
   FunctionDecl *FD = dcl ? dcl->getAsFunction() : nullptr;
 
-  if (FSI->UsesFPIntrin && !FD->hasAttr<StrictFPAttr>())
+  if (FSI->UsesFPIntrin && FD && !FD->hasAttr<StrictFPAttr>())
     FD->addAttr(StrictFPAttr::CreateImplicit(Context));
 
   sema::AnalysisBasedWarnings::Policy WP = AnalysisWarnings.getDefaultPolicy();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110315.374541.patch
Type: text/x-patch
Size: 894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210923/efe13cd0/attachment.bin>


More information about the cfe-commits mailing list