From fac68c3d8c64c55473b44bba9a49e3283d14c0e1 Mon Sep 17 00:00:00 2001 From: Graham Nelson Date: Sun, 10 Apr 2022 16:39:42 +0100 Subject: [PATCH] Marking Errors::internal_error_handler as _Noreturn --- Materials/macos-make-settings.mk | 6 ++- README.md | 2 +- Tangled/inweb.c | 38 ++++++++++--------- build.txt | 4 +- docs/foundation-module/3-em.html | 7 +++- docs/goldbach/goldbach.pdf | Bin 251998 -> 251998 bytes foundation-module/Chapter 3/Error Messages.w | 7 +++- foundation-test/foundation-test.mk | 6 ++- 8 files changed, 43 insertions(+), 27 deletions(-) diff --git a/Materials/macos-make-settings.mk b/Materials/macos-make-settings.mk index 8b865a3..325f813 100644 --- a/Materials/macos-make-settings.mk +++ b/Materials/macos-make-settings.mk @@ -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 diff --git a/README.md b/README.md index df85c82..2e9b6f2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Tangled/inweb.c b/Tangled/inweb.c index 80cea1f..1cd3b22 100644 --- a/Tangled/inweb.c +++ b/Tangled/inweb.c @@ -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" diff --git a/build.txt b/build.txt index 2f16325..f22db0b 100644 --- a/build.txt +++ b/build.txt @@ -1,3 +1,3 @@ Prerelease: alpha.1 -Build Date: 8 April 2022 -Build Number: 1A86 +Build Date: 10 April 2022 +Build Number: 1A87 diff --git a/docs/foundation-module/3-em.html b/docs/foundation-module/3-em.html index 74e9df3..90c2f45 100644 --- a/docs/foundation-module/3-em.html +++ b/docs/foundation-module/3-em.html @@ -129,17 +129,22 @@ the temporary stream, not some other string which might need fresh allocation. DISCARD_TEXT(ERM) } -

§3. Assertion failures lead to the following: +

§3. 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.)

define 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
 }
 

§4. Deliberately crashing. It's sometimes convenient to get a backtrace from the debugger when an error diff --git a/docs/goldbach/goldbach.pdf b/docs/goldbach/goldbach.pdf index 8fb8a228ba944ac25d49b44886c9c9a37ce64370..8e295c2aa68033c170fe14e4d43506440ee999dd 100644 GIT binary patch delta 138 zcmcb&f&bnH{)QID7N#xCd?&RH4GhhUEsZR+4Gh%{4AeEb^nLSFToOxC6*OF|j0}v7 z3`}53wp*TLUdQWX;bP`u;c8}LWa8#zVr*z`;biJ+WNd0_VB%zK?&|1br(i=s$#%`_ H%%+S0E~q0~ delta 138 zcmcb&f&bnH{)QID7N#xCd?&RHEDQ|{j0{Y*4Gh%{4AeEb^nLSFToOxC6*OF|j0}v7 z3`}53wp*TLUdQWX=4k5TWNv9_=wf8*Vrk%JYHH}_WMN?9Xl!8NW@_eQr(i=s$#%`_ H%%+S0A-y9k diff --git a/foundation-module/Chapter 3/Error Messages.w b/foundation-module/Chapter 3/Error Messages.w index 425f8a8..9f4f74c 100644 --- a/foundation-module/Chapter 3/Error Messages.w +++ b/foundation-module/Chapter 3/Error Messages.w @@ -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. diff --git a/foundation-test/foundation-test.mk b/foundation-test/foundation-test.mk index 05b938b..8ba1ff6 100644 --- a/foundation-test/foundation-test.mk +++ b/foundation-test/foundation-test.mk @@ -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