Skip to content

Commit ea437a6

Browse files
committed
CHANGE: use noreturn attribute in Trap* functions and mark these as DEAD_END to silence compiler warnings
1 parent 9a3a117 commit ea437a6

17 files changed

+81
-63
lines changed

src/core/c-error.c

+33-16
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2024 Rebol Open Source Developers
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -504,168 +505,183 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
504505

505506
/***********************************************************************
506507
**
507-
*/ void Trap0(REBCNT num)
508+
*/ REB_NORETURN void Trap0(REBCNT num)
508509
/*
509510
***********************************************************************/
510511
{
511512
Throw_Error(Make_Error(num, 0, 0, 0));
513+
DEAD_END;
512514
}
513515

514516

515517
/***********************************************************************
516518
**
517-
*/ void Trap1(REBCNT num, REBVAL *arg1)
519+
*/ REB_NORETURN void Trap1(REBCNT num, REBVAL *arg1)
518520
/*
519521
***********************************************************************/
520522
{
521523
Throw_Error(Make_Error(num, arg1, 0, 0));
524+
DEAD_END;
522525
}
523526

524527

525528
/***********************************************************************
526529
**
527-
*/ void Trap2(REBCNT num, REBVAL *arg1, REBVAL *arg2)
530+
*/ REB_NORETURN void Trap2(REBCNT num, REBVAL *arg1, REBVAL *arg2)
528531
/*
529532
***********************************************************************/
530533
{
531534
Throw_Error(Make_Error(num, arg1, arg2, 0));
535+
DEAD_END;
532536
}
533537

534538

535539
/***********************************************************************
536540
**
537-
*/ void Trap3(REBCNT num, REBVAL *arg1, REBVAL *arg2, REBVAL *arg3)
541+
*/ REB_NORETURN void Trap3(REBCNT num, REBVAL *arg1, REBVAL *arg2, REBVAL *arg3)
538542
/*
539543
***********************************************************************/
540544
{
541545
Throw_Error(Make_Error(num, arg1, arg2, arg3));
546+
DEAD_END;
542547
}
543548

544549

545550
/***********************************************************************
546551
**
547-
*/ void Trap_Arg(REBVAL *arg)
552+
*/ REB_NORETURN void Trap_Arg(REBVAL *arg)
548553
/*
549554
***********************************************************************/
550555
{
551556
Trap1(RE_INVALID_ARG, arg);
557+
DEAD_END;
552558
}
553559

554560

555561
/***********************************************************************
556562
**
557-
*/ void Trap_Type(REBVAL *arg)
563+
*/ REB_NORETURN void Trap_Type(REBVAL *arg)
558564
/*
559565
** <type> type is not allowed here
560566
**
561567
***********************************************************************/
562568
{
563569
Trap1(RE_INVALID_TYPE, Of_Type(arg));
570+
DEAD_END;
564571
}
565572

566573

567574
/***********************************************************************
568575
**
569-
*/ void Trap_Range(REBVAL *arg)
576+
*/ REB_NORETURN void Trap_Range(REBVAL *arg)
570577
/*
571578
** value out of range: <value>
572579
**
573580
***********************************************************************/
574581
{
575582
Trap1(RE_OUT_OF_RANGE, arg);
583+
DEAD_END;
576584
}
577585

578586

579587
/***********************************************************************
580588
**
581-
*/ void Trap_Word(REBCNT num, REBCNT sym, REBVAL *arg)
589+
*/ REB_NORETURN void Trap_Word(REBCNT num, REBCNT sym, REBVAL *arg)
582590
/*
583591
***********************************************************************/
584592
{
585593
Init_Word(DS_TOP, sym);
586594
if (arg) Trap2(num, DS_TOP, arg);
587595
else Trap1(num, DS_TOP);
596+
DEAD_END;
588597
}
589598

590599

591600
/***********************************************************************
592601
**
593-
*/ void Trap_Action(REBCNT type, REBCNT action)
602+
*/ REB_NORETURN void Trap_Action(REBCNT type, REBCNT action)
594603
/*
595604
***********************************************************************/
596605
{
597606
Trap2(RE_CANNOT_USE, Get_Action_Word(action), Get_Type(type));
607+
DEAD_END;
598608
}
599609

600610

601611
/***********************************************************************
602612
**
603-
*/ void Trap_Math_Args(REBCNT type, REBCNT action)
613+
*/ REB_NORETURN void Trap_Math_Args(REBCNT type, REBCNT action)
604614
/*
605615
***********************************************************************/
606616
{
607617
Trap2(RE_NOT_RELATED, Get_Action_Word(action), Get_Type(type));
618+
DEAD_END;
608619
}
609620

610621

611622
/***********************************************************************
612623
**
613-
*/ void Trap_Types(REBCNT errnum, REBCNT type1, REBCNT type2)
624+
*/ REB_NORETURN void Trap_Types(REBCNT errnum, REBCNT type1, REBCNT type2)
614625
/*
615626
***********************************************************************/
616627
{
617628
if (type2 != 0) Trap2(errnum, Get_Type(type1), Get_Type(type2));
618629
Trap1(errnum, Get_Type(type1));
630+
DEAD_END;
619631
}
620632

621633

622634
/***********************************************************************
623635
**
624-
*/ void Trap_Expect(REBVAL *object, REBCNT index, REBCNT type)
636+
*/ REB_NORETURN void Trap_Expect(REBVAL *object, REBCNT index, REBCNT type)
625637
/*
626638
** Object field is not of expected type.
627639
** PORT expected SCHEME of OBJECT type
628640
**
629641
***********************************************************************/
630642
{
631643
Trap3(RE_EXPECT_TYPE, Of_Type(object), Obj_Word(object, index), Get_Type(type));
644+
DEAD_END;
632645
}
633646

634647

635648
/***********************************************************************
636649
**
637-
*/ void Trap_Make(REBCNT type, REBVAL *spec)
650+
*/ REB_NORETURN void Trap_Make(REBCNT type, REBVAL *spec)
638651
/*
639652
***********************************************************************/
640653
{
641654
Trap2(RE_BAD_MAKE_ARG, Get_Type(type), spec);
655+
DEAD_END;
642656
}
643657

644658

645659
/***********************************************************************
646660
**
647-
*/ void Trap_Num(REBCNT err, REBCNT num)
661+
*/ REB_NORETURN void Trap_Num(REBCNT err, REBCNT num)
648662
/*
649663
***********************************************************************/
650664
{
651665
DS_PUSH_INTEGER(num);
652666
Trap1(err, DS_TOP);
667+
DEAD_END;
653668
}
654669

655670

656671
/***********************************************************************
657672
**
658-
*/ void Trap_Reflect(REBCNT type, REBVAL *arg)
673+
*/ REB_NORETURN void Trap_Reflect(REBCNT type, REBVAL *arg)
659674
/*
660675
***********************************************************************/
661676
{
662677
Trap2(RE_CANNOT_USE, arg, Get_Type(type));
678+
DEAD_END;
663679
}
664680

665681

666682
/***********************************************************************
667683
**
668-
*/ void Trap_Port(REBCNT errnum, REBSER *port, REBINT err_code)
684+
*/ REB_NORETURN void Trap_Port(REBCNT errnum, REBSER *port, REBINT err_code)
669685
/*
670686
***********************************************************************/
671687
{
@@ -679,6 +695,7 @@ static REBOL_STATE Top_State; // Boot var: holds error state during boot
679695

680696
DS_PUSH_INTEGER(-err_code);
681697
Trap2(errnum, val, DS_TOP);
698+
DEAD_END;
682699
}
683700

684701

src/core/d-crash.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6-
** Copyright 2012-2023 Rebol Open Source Developers
6+
** Copyright 2012-2024 Rebol Open Source Developers
77
** REBOL is a trademark of REBOL Technologies
88
**
99
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -121,8 +121,8 @@ enum Crash_Msg_Nums {
121121
#else
122122
OS_CRASH(Crash_Msgs[CM_ERROR], buf);
123123
#endif
124-
// will not reach here, but...
125-
abort(); // just to silent the function declared 'noreturn' should not return warning
124+
// will not reach here...
125+
DEAD_END;
126126
}
127127

128128
/***********************************************************************

src/core/f-stubs.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2024 Rebol Open Source Developers
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -172,7 +173,6 @@
172173
return n;
173174

174175
Trap_Range(val);
175-
return 0;
176176
}
177177

178178

@@ -186,7 +186,6 @@
186186
if (IS_DECIMAL(val) || IS_PERCENT(val)) return (REBI64)VAL_DECIMAL(val);
187187
if (IS_MONEY(val)) return deci_to_int(VAL_DECI(val));
188188
Trap_Arg(val);
189-
return 0;
190189
}
191190

192191

@@ -200,7 +199,6 @@
200199
if (IS_INTEGER(val)) return (REBDEC)VAL_INT64(val);
201200
if (IS_MONEY(val)) return deci_to_decimal(VAL_DECI(val));
202201
Trap_Arg(val);
203-
return 0;
204202
}
205203

206204

@@ -235,7 +233,6 @@
235233
return n;
236234

237235
Trap_Range(val);
238-
DEAD_END;
239236
}
240237

241238

@@ -612,7 +609,6 @@
612609
if (IS_LOGIC(arg)) return (VAL_LOGIC(arg) != 0);
613610
if (IS_DECIMAL(arg) || IS_PERCENT(arg)) return (VAL_DECIMAL(arg) != 0.0);
614611
Trap_Arg(arg);
615-
DEAD_END;
616612
}
617613

618614

src/core/n-data.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6-
** Copyright 2012-2023 Rebol Open Source Developers
6+
** Copyright 2012-2024 Rebol Open Source Developers
77
** REBOL is a trademark of REBOL Technologies
88
**
99
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -154,8 +154,6 @@ static int Check_Char_Range(REBVAL *val, REBINT limit)
154154
}
155155

156156
Trap_Arg(types);
157-
158-
return 0; // for compiler
159157
}
160158

161159

src/core/p-checksum.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6-
** Copyright 2012-2023 Rebol Open Source Contributors
6+
** Copyright 2012-2024 Rebol Open Source Contributors
77
** REBOL is a trademark of REBOL Technologies
88
**
99
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -284,7 +284,6 @@
284284
method = Obj_Value(spec, STD_PORT_SPEC_CHECKSUM_METHOD);
285285
if (!method || !IS_WORD(method)) {
286286
Trap1(RE_INVALID_SPEC, spec);
287-
return 0; //just to make xcode analyze happy
288287
}
289288

290289
req = Use_Port_State(port, RDI_CHECKSUM, sizeof(REBREQ));

src/core/p-crypt.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6-
** Copyright 2012-2023 Rebol Open Source Contributors
6+
** Copyright 2012-2024 Rebol Open Source Contributors
77
** REBOL is a trademark of REBOL Technologies
88
**
99
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -478,7 +478,6 @@ static void free_crypt_cipher_context(CRYPT_CTX *ctx);
478478
Trap1(RE_INVALID_SPEC, spec);
479479
}
480480
Trap_Port(RE_CANNOT_OPEN, port, err);
481-
return FALSE;
482481
}
483482

484483

@@ -1037,7 +1036,6 @@ static void free_crypt_cipher_context(CRYPT_CTX *ctx);
10371036
}
10381037
if (!Crypt_Open(port)) {
10391038
Trap_Port(RE_CANNOT_OPEN, port, 0);
1040-
return R_FALSE;
10411039
}
10421040
return R_ARG1;
10431041
}

src/core/p-net.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ enum Transport_Types {
113113

114114
if (!info || !IS_OBJECT(info)) {
115115
Trap_Port(RE_INVALID_SPEC, port, -10);
116-
return; // prevents compiler's warning
116+
DEAD_END;
117117
}
118118

119119
obj = CLONE_OBJECT(VAL_OBJ_FRAME(info));

src/core/t-char.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2024 Rebol Open Source Developers
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -72,7 +73,6 @@
7273
arg = (REBINT)VAL_DECIMAL(val);
7374
else {
7475
Trap_Math_Args(REB_CHAR, action);
75-
return R_NONE; // just to make xcode happy
7676
}
7777
}
7878

src/core/t-gob.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2024 Rebol Open Source Developers
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -792,7 +793,6 @@ const REBCNT Gob_Flag_Words[] = {
792793
tail = GOB_PANE(gob) ? GOB_TAIL(gob) : 0;
793794
} else if (!(IS_DATATYPE(val) && action == A_MAKE)){
794795
Trap_Arg(val);
795-
return R_FALSE; // shut-up compiler's warnings
796796
}
797797

798798
// unary actions

0 commit comments

Comments
 (0)