[clang] 3778c1c - [Sema] Fix a null pointer reference crash.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 23 07:37:50 PDT 2021
Author: Haojian Wu
Date: 2021-09-23T16:37:37+02:00
New Revision: 3778c1cd6ef5a3286d5d49e842a2c65fffb8f3a6
URL: https://github.com/llvm/llvm-project/commit/3778c1cd6ef5a3286d5d49e842a2c65fffb8f3a6
DIFF: https://github.com/llvm/llvm-project/commit/3778c1cd6ef5a3286d5d49e842a2c65fffb8f3a6.diff
LOG: [Sema] Fix a null pointer reference crash.
Differential Revision: https://reviews.llvm.org/D110315
Added:
clang/test/SemaCXX/rounding-math-crash.cpp
Modified:
clang/lib/Sema/SemaDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 79080098026c6..db7c9f9418042 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -14493,7 +14493,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
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();
diff --git a/clang/test/SemaCXX/rounding-math-crash.cpp b/clang/test/SemaCXX/rounding-math-crash.cpp
new file mode 100644
index 0000000000000..32f1fc0f792c3
--- /dev/null
+++ b/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}}
More information about the cfe-commits
mailing list