Marking Errors::internal_error_handler as _Noreturn
This commit is contained in:
parent
6b36028958
commit
fac68c3d8c
8 changed files with 43 additions and 27 deletions
|
@ -49,10 +49,12 @@ CCOPTS = -DPLATFORM_MACOS=1 -mmacosx-version-min=10.6 -arch x86_64 -isysroot /Ap
|
|||
# -Wno-strict-prototypes: in OS X 10.13, clang began objecting to (some) function prototypes generated by macros
|
||||
# -Wno-extra-semi-stmt: in OS X 10.15, clang began objecting to redundant semicolons after macros had expanded,
|
||||
# which is a little tiresome: though it's off by default (on MacOS with -Weverything), we explicitly disable it
|
||||
# -Wno-c11-extensions: we want to allow ourselves use of _Noreturn, a C11 annotation...
|
||||
# -Wno-unreachable-code-return: ...which means some compilers can prove some of our return statements unnecessary
|
||||
|
||||
MANYWARNINGS = -Weverything -Wno-pointer-arith -Wno-unused-macros -Wno-shadow -Wno-cast-align -Wno-variadic-macros -Wno-missing-noreturn -Wno-missing-prototypes -Wno-unused-parameter -Wno-padded -Wno-missing-variable-declarations -Wno-unreachable-code-break -Wno-class-varargs -Wno-format-nonliteral -Wno-cast-qual -Wno-double-promotion -Wno-comma -Wno-strict-prototypes -Wno-extra-semi-stmt -ferror-limit=1000
|
||||
MANYWARNINGS = -Weverything -Wno-pointer-arith -Wno-unused-macros -Wno-shadow -Wno-cast-align -Wno-variadic-macros -Wno-missing-noreturn -Wno-missing-prototypes -Wno-unused-parameter -Wno-padded -Wno-missing-variable-declarations -Wno-unreachable-code-break -Wno-class-varargs -Wno-format-nonliteral -Wno-cast-qual -Wno-double-promotion -Wno-comma -Wno-strict-prototypes -Wno-extra-semi-stmt -Wno-c11-extensions -Wno-unreachable-code-return -ferror-limit=1000
|
||||
|
||||
FEWERWARNINGS = -Wno-implicit-int -Wno-dangling-else -Wno-pointer-sign -Wno-format-extra-args -Wno-tautological-compare -Wno-deprecated-declarations -Wno-logical-op-parentheses -Wno-format -Wno-extra-semi-stmt
|
||||
FEWERWARNINGS = -Wno-implicit-int -Wno-dangling-else -Wno-pointer-sign -Wno-format-extra-args -Wno-tautological-compare -Wno-deprecated-declarations -Wno-logical-op-parentheses -Wno-format -Wno-extra-semi-stmt -Wno-c11-extensions -Wno-unreachable-code-return
|
||||
|
||||
# (2) We need a linker, "LINK". Nowadays some C compilers (e.g. clang on
|
||||
# Mac OS X) can happily do their own linking, but on some Unix platforms
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Inweb 7
|
||||
|
||||
v7-alpha.1+1A86 'Escape to Danger' (8 April 2022)
|
||||
v7-alpha.1+1A87 'Escape to Danger' (10 April 2022)
|
||||
|
||||
## About Inweb
|
||||
|
||||
|
|
|
@ -2950,25 +2950,25 @@ void Errors__fatal_with_text(char *message, text_stream *parameter) ;
|
|||
void Errors__fatal_with_file(char *message, filename *F) ;
|
||||
#line 75 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__fatal_with_path(char *message, pathname *P) ;
|
||||
#line 87 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 91 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__internal_error_handler(void *p, char *message, char *f, int lc) ;
|
||||
#line 101 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__enter_debugger_mode(void) ;
|
||||
#line 106 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__enter_debugger_mode(void) ;
|
||||
#line 111 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__die(void) ;
|
||||
#line 122 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 127 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__nowhere(char *message) ;
|
||||
#line 126 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 131 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__in_text_file(char *message, text_file_position *here) ;
|
||||
#line 133 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 138 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__in_text_file_S(text_stream *message, text_file_position *here) ;
|
||||
#line 143 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 148 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__at_position(char *message, filename *file, int line) ;
|
||||
#line 152 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 157 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__at_position_S(text_stream *message, filename *file, int line) ;
|
||||
#line 164 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 169 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__with_file(char *message, filename *F) ;
|
||||
#line 171 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 176 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__with_text(char *message, text_stream *T) ;
|
||||
#line 65 "inweb/foundation-module/Chapter 3/Command Line Arguments.w"
|
||||
void CommandLine__begin_group(int id, text_stream *name) ;
|
||||
|
@ -8240,15 +8240,17 @@ void Errors__fatal_with_path(char *message, pathname *P) {
|
|||
DISCARD_TEXT(ERM)
|
||||
}
|
||||
|
||||
#line 87 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 90 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
_Noreturn
|
||||
void Errors__internal_error_handler(void *p, char *message, char *f, int lc) {
|
||||
if (internal_errors_handler)
|
||||
(*internal_errors_handler)(p, message, f, lc);
|
||||
else
|
||||
Errors__fatal_with_C_string("internal error (%s)", message);
|
||||
exit(1); /* redundant but needed to remove compiler warning in clang */
|
||||
}
|
||||
|
||||
#line 100 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 105 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
int debugger_mode = FALSE;
|
||||
void Errors__enter_debugger_mode(void) {
|
||||
debugger_mode = TRUE;
|
||||
|
@ -8266,7 +8268,7 @@ void Errors__die(void) { /* as void as it gets */
|
|||
exit(2);
|
||||
}
|
||||
|
||||
#line 122 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 127 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__nowhere(char *message) {
|
||||
Errors__in_text_file(message, NULL);
|
||||
}
|
||||
|
@ -8285,7 +8287,7 @@ void Errors__in_text_file_S(text_stream *message, text_file_position *here) {
|
|||
Errors__at_position_S(message, NULL, 0);
|
||||
}
|
||||
|
||||
#line 143 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 148 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__at_position(char *message, filename *file, int line) {
|
||||
TEMPORARY_TEXT(ERM)
|
||||
WRITE_TO(ERM, "%s: ", PROGRAM_NAME);
|
||||
|
@ -8304,7 +8306,7 @@ void Errors__at_position_S(text_stream *message, filename *file, int line) {
|
|||
DISCARD_TEXT(ERM)
|
||||
}
|
||||
|
||||
#line 164 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
#line 169 "inweb/foundation-module/Chapter 3/Error Messages.w"
|
||||
void Errors__with_file(char *message, filename *F) {
|
||||
TEMPORARY_TEXT(ERM)
|
||||
WRITE_TO(ERM, "%s: %f: %s\n", PROGRAM_NAME, F, message);
|
||||
|
@ -8594,11 +8596,11 @@ int CommandLine__read_pair_p(text_stream *opt, text_stream *opt_val, int N,
|
|||
; innocuous = TRUE; break;
|
||||
case VERSION_CLSW: {
|
||||
PRINT("inweb");
|
||||
char *svn = "7-alpha.1+1A85";
|
||||
char *svn = "7-alpha.1+1A86";
|
||||
if (svn[0]) PRINT(" version %s", svn);
|
||||
char *vname = "Escape to Danger";
|
||||
if (vname[0]) PRINT(" '%s'", vname);
|
||||
char *d = "7 April 2022";
|
||||
char *d = "8 April 2022";
|
||||
if (d[0]) PRINT(" (%s)", d);
|
||||
PRINT("\n");
|
||||
innocuous = TRUE; break;
|
||||
|
@ -30936,7 +30938,7 @@ void Ctags__write(web *W, filename *F) {
|
|||
WRITE("!_TAG_FILE_SORTED\t0\t/0=unsorted, 1=sorted, 2=foldcase/\n");
|
||||
WRITE("!_TAG_PROGRAM_AUTHOR\tGraham Nelson\t/graham.nelson@mod-langs.ox.ac.uk/\n");
|
||||
WRITE("!_TAG_PROGRAM_NAME\tinweb\t//\n");
|
||||
WRITE("!_TAG_PROGRAM_VERSION\t7-alpha.1+1A85\t/built 7 April 2022/\n");
|
||||
WRITE("!_TAG_PROGRAM_VERSION\t7-alpha.1+1A86\t/built 8 April 2022/\n");
|
||||
|
||||
}
|
||||
#line 47 "inweb/Chapter 6/Ctags Support.w"
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
Prerelease: alpha.1
|
||||
Build Date: 8 April 2022
|
||||
Build Number: 1A86
|
||||
Build Date: 10 April 2022
|
||||
Build Number: 1A87
|
||||
|
|
|
@ -129,17 +129,22 @@ the temporary stream, not some other string which might need fresh allocation.
|
|||
<span class="plain-syntax"> </span><span class="identifier-syntax">DISCARD_TEXT</span><span class="plain-syntax">(</span><span class="identifier-syntax">ERM</span><span class="plain-syntax">)</span>
|
||||
<span class="plain-syntax">}</span>
|
||||
</pre>
|
||||
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>§3. </b>Assertion failures lead to the following:
|
||||
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>§3. </b>Assertion failures lead to the following. Note the use of the C11 syntax
|
||||
<span class="extract"><span class="extract-syntax">_Noreturn</span></span>; this seems now to be well-supported on modern C compilers, though.
|
||||
(It needs to be on its own line to avoid hassle with InC, which has no special
|
||||
support for C annotations.)
|
||||
</p>
|
||||
|
||||
<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="identifier-syntax">internal_error</span><span class="plain-syntax">(</span><span class="identifier-syntax">message</span><span class="plain-syntax">) </span><a href="3-em.html#SP3" class="function-link"><span class="function-syntax">Errors::internal_error_handler</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="identifier-syntax">__FILE__</span><span class="plain-syntax">, </span><span class="identifier-syntax">__LINE__</span><span class="plain-syntax">)</span>
|
||||
</pre>
|
||||
<pre class="displayed-code all-displayed-code code-font">
|
||||
<span class="identifier-syntax">_Noreturn</span>
|
||||
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Errors::internal_error_handler</span><span class="plain-syntax">(</span><span class="reserved-syntax">void</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="reserved-syntax">char</span><span class="plain-syntax"> *</span><span class="identifier-syntax">f</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">lc</span><span class="plain-syntax">) {</span>
|
||||
<span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">internal_errors_handler</span><span class="plain-syntax">)</span>
|
||||
<span class="plain-syntax"> (*</span><span class="identifier-syntax">internal_errors_handler</span><span class="plain-syntax">)(</span><span class="identifier-syntax">p</span><span class="plain-syntax">, </span><span class="identifier-syntax">message</span><span class="plain-syntax">, </span><span class="identifier-syntax">f</span><span class="plain-syntax">, </span><span class="identifier-syntax">lc</span><span class="plain-syntax">);</span>
|
||||
<span class="plain-syntax"> </span><span class="reserved-syntax">else</span>
|
||||
<span class="plain-syntax"> </span><a href="3-em.html#SP2" class="function-link"><span class="function-syntax">Errors::fatal_with_C_string</span></a><span class="plain-syntax">(</span><span class="string-syntax">"internal error (%s)"</span><span class="plain-syntax">, </span><span class="identifier-syntax">message</span><span class="plain-syntax">);</span>
|
||||
<span class="plain-syntax"> </span><span class="identifier-syntax">exit</span><span class="plain-syntax">(1); </span><span class="comment-syntax"> redundant but needed to remove compiler warning in clang</span>
|
||||
<span class="plain-syntax">}</span>
|
||||
</pre>
|
||||
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>§4. Deliberately crashing. </b>It's sometimes convenient to get a backtrace from the debugger when an error
|
||||
|
|
Binary file not shown.
|
@ -79,16 +79,21 @@ void Errors::fatal_with_path(char *message, pathname *P) {
|
|||
DISCARD_TEXT(ERM)
|
||||
}
|
||||
|
||||
@ Assertion failures lead to the following:
|
||||
@ Assertion failures lead to the following. Note the use of the C11 syntax
|
||||
|_Noreturn|; this seems now to be well-supported on modern C compilers, though.
|
||||
(It needs to be on its own line to avoid hassle with InC, which has no special
|
||||
support for C annotations.)
|
||||
|
||||
@d internal_error(message) Errors::internal_error_handler(NULL, message, __FILE__, __LINE__)
|
||||
|
||||
=
|
||||
_Noreturn
|
||||
void Errors::internal_error_handler(void *p, char *message, char *f, int lc) {
|
||||
if (internal_errors_handler)
|
||||
(*internal_errors_handler)(p, message, f, lc);
|
||||
else
|
||||
Errors::fatal_with_C_string("internal error (%s)", message);
|
||||
exit(1); /* redundant but needed to remove compiler warning in clang */
|
||||
}
|
||||
|
||||
@h Deliberately crashing.
|
||||
|
|
|
@ -9,13 +9,15 @@ INDULGENTCC = clang -std=c99 -c $(FEWERWARNINGS) $(CCOPTS) -g
|
|||
|
||||
CCOPTS = -DPLATFORM_MACOS=1 -mmacosx-version-min=10.6 -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
|
||||
|
||||
MANYWARNINGS = -Weverything -Wno-pointer-arith -Wno-unused-macros -Wno-shadow -Wno-cast-align -Wno-variadic-macros -Wno-missing-noreturn -Wno-missing-prototypes -Wno-unused-parameter -Wno-padded -Wno-missing-variable-declarations -Wno-unreachable-code-break -Wno-class-varargs -Wno-format-nonliteral -Wno-cast-qual -Wno-double-promotion -Wno-comma -Wno-strict-prototypes -Wno-extra-semi-stmt -ferror-limit=1000
|
||||
MANYWARNINGS = -Weverything -Wno-pointer-arith -Wno-unused-macros -Wno-shadow -Wno-cast-align -Wno-variadic-macros -Wno-missing-noreturn -Wno-missing-prototypes -Wno-unused-parameter -Wno-padded -Wno-missing-variable-declarations -Wno-unreachable-code-break -Wno-class-varargs -Wno-format-nonliteral -Wno-cast-qual -Wno-double-promotion -Wno-comma -Wno-strict-prototypes -Wno-extra-semi-stmt -Wno-c11-extensions -Wno-unreachable-code-return -ferror-limit=1000
|
||||
|
||||
FEWERWARNINGS = -Wno-implicit-int -Wno-dangling-else -Wno-pointer-sign -Wno-format-extra-args -Wno-tautological-compare -Wno-deprecated-declarations -Wno-logical-op-parentheses -Wno-format -Wno-extra-semi-stmt
|
||||
FEWERWARNINGS = -Wno-implicit-int -Wno-dangling-else -Wno-pointer-sign -Wno-format-extra-args -Wno-tautological-compare -Wno-deprecated-declarations -Wno-logical-op-parentheses -Wno-format -Wno-extra-semi-stmt -Wno-c11-extensions -Wno-unreachable-code-return
|
||||
|
||||
LINK = clang $(CCOPTS) -g
|
||||
LINKEROPTS =
|
||||
|
||||
EXEEXTENSION =
|
||||
|
||||
ARTOOL = libtool -o
|
||||
|
||||
INFORM6OS = OSX
|
||||
|
|
Loading…
Reference in a new issue