From a130e799292e775ff28bb45288c221332b566d5f Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Sun, 19 Jan 2020 14:57:28 -0600 Subject: [PATCH] Prohibit _Noreturn specifier on non-functions. --- Parser.pas | 4 ++++ Scanner.pas | 1 + 2 files changed, 5 insertions(+) diff --git a/Parser.pas b/Parser.pas index d895cbf..01b4f68 100644 --- a/Parser.pas +++ b/Parser.pas @@ -3122,6 +3122,7 @@ var i: integer; {loop variable} isAsm: boolean; {has the asm modifier been used?} isInline: boolean; {has the inline specifier been used?} + isNoreturn: boolean; {has the _Noreturn specifier been used?} lDoingParameters: boolean; {local copy of doingParameters} lisPascal: boolean; {local copy of isPascal} lp,tlp,tlp2: identPtr; {for tracing parameter list} @@ -3367,6 +3368,7 @@ DeclarationSpecifiers(declarationSpecifiersElement, ident); isPascal := pascalsy in functionSpecifiers; isAsm := asmsy in functionSpecifiers; isInline := inlinesy in functionSpecifiers; +isNoreturn := _Noreturnsy in functionSpecifiers; lisPascal := isPascal; if not skipDeclarator then begin variable := nil; @@ -3657,6 +3659,8 @@ else {if not isFunction then} begin end; {if} if isInline then Error(119); + if isNoreturn then + Error(141); if token.kind = eqch then begin if storageClass = typedefsy then Error(52); diff --git a/Scanner.pas b/Scanner.pas index 801ca64..3381588 100644 --- a/Scanner.pas +++ b/Scanner.pas @@ -662,6 +662,7 @@ if list or (numErr <> 0) then begin 138: msg := @'unsupported alignment'; 139: msg := @'thread-local storage is not supported by ORCA/C'; 140: msg := @'unexpected token'; + 141: msg := @'_Noreturn specifier is only allowed on functions'; otherwise: Error(57); end; {case} writeln(msg^);