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();


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();
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to