Emit an error when attempting to generate IR for SEH __try
Currently we silently omit the code in the try and finally bodies, which
is pretty bad. This way we fail loudly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190809 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 0c2cfc4..1748621 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -1697,3 +1697,7 @@
return EHResumeBlock;
}
+
+void CodeGenFunction::EmitSEHTryStmt(const SEHTryStmt &S) {
+ CGM.ErrorUnsupported(&S, "SEH __try");
+}
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp
index e309540..4492ea9 100644
--- a/lib/CodeGen/CGStmt.cpp
+++ b/lib/CodeGen/CGStmt.cpp
@@ -168,8 +168,9 @@
break;
case Stmt::CXXForRangeStmtClass:
EmitCXXForRangeStmt(cast<CXXForRangeStmt>(*S));
+ break;
case Stmt::SEHTryStmtClass:
- // FIXME Not yet implemented
+ EmitSEHTryStmt(cast<SEHTryStmt>(*S));
break;
}
}
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index 20c0b82..5889d05 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -1838,6 +1838,7 @@
void ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock = false);
void EmitCXXTryStmt(const CXXTryStmt &S);
+ void EmitSEHTryStmt(const SEHTryStmt &S);
void EmitCXXForRangeStmt(const CXXForRangeStmt &S);
llvm::Function *EmitCapturedStmt(const CapturedStmt &S, CapturedRegionKind K);
diff --git a/test/CodeGen/exceptions-seh.c b/test/CodeGen/exceptions-seh.c
new file mode 100644
index 0000000..eadbe15
--- /dev/null
+++ b/test/CodeGen/exceptions-seh.c
@@ -0,0 +1,18 @@
+// RUN: not %clang_cc1 -triple i686-pc-win32 -fexceptions -fms-extensions -emit-llvm -o - %s 2>&1 | FileCheck %s
+
+// This is a codegen test because we only emit the diagnostic when we start
+// generating code.
+
+int SaveDiv(int numerator, int denominator, int *res) {
+ int myres = 0;
+ __try {
+ myres = numerator / denominator;
+ } __except (1) {
+ return 0;
+ }
+ *res = myres;
+ return 1;
+}
+// CHECK-NOT error
+// CHECK: error: cannot compile this SEH __try yet
+// CHECK-NOT error