]> granicus.if.org Git - clang/commitdiff
Emit an error when attempting to generate IR for SEH __try
authorReid Kleckner <reid@kleckner.net>
Mon, 16 Sep 2013 21:46:30 +0000 (21:46 +0000)
committerReid Kleckner <reid@kleckner.net>
Mon, 16 Sep 2013 21:46:30 +0000 (21:46 +0000)
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

lib/CodeGen/CGException.cpp
lib/CodeGen/CGStmt.cpp
lib/CodeGen/CodeGenFunction.h
test/CodeGen/exceptions-seh.c [new file with mode: 0644]

index 0c2cfc4c07bd2e4e9f21dc63f5d19a34f4591fa8..1748621da34d2f3b4507ca632ffcd2748ea0b5d2 100644 (file)
@@ -1697,3 +1697,7 @@ llvm::BasicBlock *CodeGenFunction::getEHResumeBlock(bool isCleanup) {
 
   return EHResumeBlock;
 }
+
+void CodeGenFunction::EmitSEHTryStmt(const SEHTryStmt &S) {
+  CGM.ErrorUnsupported(&S, "SEH __try");
+}
index e3095403f91bd5fd3c7c68745caa6ff39dc38717..4492ea9a8f3e2355f37e45af0d7473d7ff2e8a3a 100644 (file)
@@ -168,8 +168,9 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
     break;
   case Stmt::CXXForRangeStmtClass:
     EmitCXXForRangeStmt(cast<CXXForRangeStmt>(*S));
+    break;
   case Stmt::SEHTryStmtClass:
-    // FIXME Not yet implemented
+    EmitSEHTryStmt(cast<SEHTryStmt>(*S));
     break;
   }
 }
index 20c0b82553caf66a3bc300975d09ef559a3a0f01..5889d058606f9522f5caf13072370358a67ced57 100644 (file)
@@ -1838,6 +1838,7 @@ public:
   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 (file)
index 0000000..eadbe15
--- /dev/null
@@ -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