[PATCH] D152818: [Clang] Fix assertion when pragma FENV_ACCESS is used with a throw function.
Zahira Ammarguellat via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 13 07:46:51 PDT 2023
zahiraam created this revision.
zahiraam added a reviewer: aaron.ballman.
Herald added a project: All.
zahiraam requested review of this revision.
Herald added a project: clang.
See issue here: https://godbolt.org/z/aYME8KTdn
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D152818
Files:
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGen/pragma-fenv_access.cpp
Index: clang/test/CodeGen/pragma-fenv_access.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/pragma-fenv_access.cpp
@@ -0,0 +1,71 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions \
+// RUN: -fexceptions -emit-llvm -o - %s | FileCheck %s
+
+// expected-no-diagnostics
+
+char b;
+template <bool, class c, class> using d = c;
+template <class, class> void e();
+template <class f> auto g(f k) { auto pt = *k; }
+class n {
+public:
+ n(char *);
+};
+template <class, class aa> using i = aa;
+template <class ab> constexpr bool j = true;
+struct o {
+ using l = char;
+ using ac = l *;
+};
+template <class m> class p {
+public:
+ m ad;
+};
+template <class> struct ae;
+template <class> class q {
+public:
+ using ac = o::ac;
+ void r() { g(af.h); }
+ struct {
+ ac h;
+ } af;
+};
+class s {
+ using ag = i<char, char>;
+ using ah = q<d<j<ag>, o, ae<char>>>;
+
+public:
+ s(char *);
+ char *t() { ai.ad.r(); }
+ p<ah> ai;
+};
+using aj = s;
+class ak : n {
+public:
+ using al = n;
+ ak(aj k) : al(k.t()) {}
+};
+class u : ak {
+protected:
+ u() : ak(0) {}
+};
+class am : u {};
+class v {
+public:
+ class w : am {
+ public:
+ w(aj) {}
+ };
+};
+class x : v {
+protected:
+ void y() { throw w(&b); }
+};
+class z : x {
+public:
+ z() { y(); }
+};
+#pragma STDC FENV_ACCESS ON
+void a() { z(); }
+
+// CHECK: define dso_local void @_Z1av()
Index: clang/lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -161,6 +161,7 @@
assert((CGF.CurFuncDecl == nullptr || CGF.Builder.getIsFPConstrained() ||
isa<CXXConstructorDecl>(CGF.CurFuncDecl) ||
isa<CXXDestructorDecl>(CGF.CurFuncDecl) ||
+ isa<FunctionDecl>(CGF.CurFuncDecl) ||
(NewExceptionBehavior == llvm::fp::ebIgnore &&
NewRoundingBehavior == llvm::RoundingMode::NearestTiesToEven)) &&
"FPConstrained should be enabled on entire function");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152818.530905.patch
Type: text/x-patch
Size: 2102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230613/7b9bc648/attachment.bin>
More information about the cfe-commits
mailing list