[PATCH] D36914: Implement CFG construction for __try / __except / __leave.

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 23 13:32:50 PDT 2017


On Wed, Aug 23, 2017 at 12:11 PM, Reid Kleckner via Phabricator via
cfe-commits <cfe-commits at lists.llvm.org> wrote:

> rnk added inline comments.
>
>
> ================
> Comment at: test/Sema/warn-unreachable-ms.c:42
> +  }
> +}
> ----------------
> rnk wrote:
> > rnk wrote:
> > > Can we add a test to exercise that this builds the right CFG?
> > > ```
> > > __try {
> > >   __try {
> > >     f();
> > >   } __except(1) {
> > >     __leave; // should exit outer try
> > >   }
> > >   __leave;
> > >   f(); // expected-warning{{never be executed}}
> > > } __except(1) {
> > > }
> > > ```
> > > Sure. Did you intentionally put two __leaves in there, or do you only
> want the one in the inner __except?
> >
> > I think both are required to trigger the warning in case f() doesn't
> throw, but I could be wrong.
> I woke up this morning and realized what you meant. Is there another way
> we can check that __leave in __except exits the outer __try?


How does this look?

$ svn diff test/Sema
Index: test/Sema/warn-unreachable-ms.c
===================================================================
--- test/Sema/warn-unreachable-ms.c (revision 311564)
+++ test/Sema/warn-unreachable-ms.c (working copy)
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -triple=i686-pc-win32 -fsyntax-only -verify
-fms-extensions -Wunreachable-code
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fsyntax-only -verify
-fms-extensions -Wunreachable-code -x c++ -fcxx-exceptions -DWITH_THROW

 void f();

@@ -41,15 +42,16 @@
   }
 }

+#if defined(WITH_THROW)
 void g3() {
   __try {
     __try {
-      f();
+      throw 1;
     } __except (1) {
       __leave; // should exit outer try
     }
-    __leave;
     f(); // expected-warning{{never be executed}}
   } __except (1) {
   }
 }
+#endif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170823/54ab27af/attachment.html>


More information about the cfe-commits mailing list