libtrycatch  Check-in [d6132d89e1]

Overview
Comment:Never issue a warning if the exception is unused
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: d6132d89e16f05209ee2eb05792cbd44d7b100c0a6bf8fde2132229fcd913eab
User & Date: js on 2017-01-22 15:55:26
Other Links: manifest | tags
Context
2017-01-22
15:55
Demonstrate rethrow in the example check-in: 0a653c9820 user: js tags: trunk
15:55
Never issue a warning if the exception is unused check-in: d6132d89e1 user: js tags: trunk
15:48
Rename the include guard check-in: 86d6342f24 user: js tags: trunk
Changes

Modified example.c from [97c5c8de55] to [2d61a6f1fd].

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
33
34
35
36
37
38
39

40
41
42
43
44
45
46
47
48
49
50
51

52
53
54
55







-












-




{
	try {
		puts("try1");

		try {
			puts("try2");
		} catch (ex) {
			(void)ex;
			puts("this should not be called");
		}

		throw(5);
	} catch (ex) {
		printf("caught %d (should be 5)\n", ex);
	}

	try {
		throw(1);
		return 1;
	} catch (ex) {
		(void)ex;
	}

	return 0;
}

Modified trycatch.h from [e9c91601df] to [bac0e8a95b].

41
42
43
44
45
46
47
48
49
50



51
52
53
54
55
56
57
41
42
43
44
45
46
47



48
49
50
51
52
53
54
55
56
57







-
-
-
+
+
+







	jmp_buf TRYCATCH_CONCAT(trycatch_jmpbuf, __LINE__);		   \
	TRYCATCH_CONCAT(trycatch_frame, __LINE__) = trycatch_frame_push(); \
	trycatch_ex = setjmp(TRYCATCH_CONCAT(trycatch_jmpbuf, __LINE__));  \
	if (trycatch_ex == 0)						   \
		TRYCATCH_CONCAT(trycatch_frame, __LINE__)->jmpbuf =	   \
		    &TRYCATCH_CONCAT(trycatch_jmpbuf, __LINE__);	   \
	if (trycatch_ex == 0)
#define catch(ex)							\
	trycatch_frame_pop();						\
	for (int ex = trycatch_ex; trycatch_ex != 0; trycatch_ex = 0)
#define catch(ex)							       \
	trycatch_frame_pop();						       \
	for (int ex = trycatch_ex; trycatch_ex != 0; trycatch_ex = 0, (void)ex)
#define throw(ex) trycatch_throw(ex)
#define rethrow trycatch_throw(trycatch_ex)

struct trycatch_frame {
	jmp_buf *jmpbuf;
	struct trycatch_frame *prev;
};