Commit 6bb8aaa3 authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

rts: Add FALLTHROUGH macro

Instead of using the GCC `/* fallthrough */` syntax we now use the
`__attribute__((fallthrough))`, which Phyx says should be more portable
than the former.

Also adds a missing fallthrough annotation in the MachO linker,
fixing #14613.

Reviewers: erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, carter

GHC Trac Issues: #14613

Differential Revision: https://phabricator.haskell.org/D5292
parent 5f81952e
......@@ -196,6 +196,13 @@
#define GNUC3_ATTRIBUTE(at)
#endif
/* Used to mark a switch case that falls-through */
#if (defined(__GNUC__) && __GNUC__ >= 7) || defined(__clang__)
#define FALLTHROUGH GNU_ATTRIBUTE(fallthrough)
#else
#define FALLTHROUGH ((void)0)
#endif /* __GNUC__ >= 7 */
#if !defined(DEBUG) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
#define GNUC_ATTR_HOT __attribute__((hot))
#else
......
......@@ -449,8 +449,8 @@ check_target:
}
// fall to next
}
FALLTHROUGH;
#endif
/* fallthrough */
case BlockedOnCCall:
blockedThrowTo(cap,target,msg);
return THROWTO_BLOCKED;
......
......@@ -1536,7 +1536,7 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
case R_PPC_PLTREL24:
value -= 0x8000; /* See Note [.LCTOC1 in PPC PIC code] */
/* fallthrough */
FALLTHROUGH;
case R_PPC_REL24:
delta = value - P;
......
......@@ -1530,6 +1530,7 @@ ocGetNames_MachO(ObjectCode* oc)
secArray[i].info->macho_section = section;
secArray[i].info->relocation_info
= (MachORelocationInfo*)(oc->image + section->reloff);
FALLTHROUGH;
}
default: {
// just set the pointer to the loaded image.
......
......@@ -212,7 +212,7 @@ compactAllocateBlockInternal(Capability *cap,
case ALLOCATE_IMPORT_NEW:
dbl_link_onto(block, &g0->compact_blocks_in_import);
/* fallthrough */
FALLTHROUGH;
case ALLOCATE_IMPORT_APPEND:
ASSERT(first == NULL);
ASSERT(g == g0);
......@@ -689,17 +689,17 @@ verify_consistency_block (StgCompactNFData *str, StgCompactNFDataBlock *block)
switch (info->type) {
case CONSTR_1_0:
check_object_in_compact(str, UNTAG_CLOSURE(q->payload[0]));
/* fallthrough */
FALLTHROUGH;
case CONSTR_0_1:
p += sizeofW(StgClosure) + 1;
break;
case CONSTR_2_0:
check_object_in_compact(str, UNTAG_CLOSURE(q->payload[1]));
/* fallthrough */
FALLTHROUGH;
case CONSTR_1_1:
check_object_in_compact(str, UNTAG_CLOSURE(q->payload[0]));
/* fallthrough */
FALLTHROUGH;
case CONSTR_0_2:
p += sizeofW(StgClosure) + 2;
break;
......@@ -931,7 +931,7 @@ fixup_block(StgCompactNFDataBlock *block, StgWord *fixup_table, uint32_t count)
if (!fixup_one_pointer(fixup_table, count,
&((StgClosure*)p)->payload[0]))
return false;
/* fallthrough */
FALLTHROUGH;
case CONSTR_0_1:
p += sizeofW(StgClosure) + 1;
break;
......@@ -940,12 +940,12 @@ fixup_block(StgCompactNFDataBlock *block, StgWord *fixup_table, uint32_t count)
if (!fixup_one_pointer(fixup_table, count,
&((StgClosure*)p)->payload[1]))
return false;
/* fallthrough */
FALLTHROUGH;
case CONSTR_1_1:
if (!fixup_one_pointer(fixup_table, count,
&((StgClosure*)p)->payload[0]))
return false;
/* fallthrough */
FALLTHROUGH;
case CONSTR_0_2:
p += sizeofW(StgClosure) + 2;
break;
......@@ -999,7 +999,7 @@ fixup_block(StgCompactNFDataBlock *block, StgWord *fixup_table, uint32_t count)
break;
}
// fall through
FALLTHROUGH;
default:
debugBelch("Invalid non-NFData closure (type %d) in Compact\n",
......
......@@ -155,7 +155,7 @@ traverseWeakPtrList(void)
// otherwise, fall through...
}
/* fallthrough */
FALLTHROUGH;
case WeakPtrs:
{
......
......@@ -102,7 +102,7 @@ checkStackFrame( StgPtr c )
case UPDATE_FRAME:
ASSERT(LOOKS_LIKE_CLOSURE_PTR(((StgUpdateFrame*)c)->updatee));
/* fallthrough */
FALLTHROUGH;
case ATOMICALLY_FRAME:
case CATCH_RETRY_FRAME:
case CATCH_STM_FRAME:
......
......@@ -498,7 +498,7 @@ scavenge_block (bdescr *bd)
case FUN_1_0:
scavenge_fun_srt(info);
/* fallthrough */
FALLTHROUGH;
case CONSTR_1_0:
evacuate(&((StgClosure *)p)->payload[0]);
p += sizeofW(StgHeader) + 1;
......@@ -511,7 +511,7 @@ scavenge_block (bdescr *bd)
case FUN_0_1:
scavenge_fun_srt(info);
/* fallthrough */
FALLTHROUGH;
case CONSTR_0_1:
p += sizeofW(StgHeader) + 1;
break;
......@@ -523,7 +523,7 @@ scavenge_block (bdescr *bd)
case FUN_0_2:
scavenge_fun_srt(info);
/* fallthrough */
FALLTHROUGH;
case CONSTR_0_2:
p += sizeofW(StgHeader) + 2;
break;
......@@ -536,7 +536,7 @@ scavenge_block (bdescr *bd)
case FUN_1_1:
scavenge_fun_srt(info);
/* fallthrough */
FALLTHROUGH;
case CONSTR_1_1:
evacuate(&((StgClosure *)p)->payload[0]);
p += sizeofW(StgHeader) + 2;
......@@ -1738,7 +1738,7 @@ scavenge_static(void)
case FUN_STATIC:
scavenge_fun_srt(info);
/* fallthrough */
FALLTHROUGH;
// a FUN_STATIC can also be an SRT, so it may have pointer
// fields. See Note [SRTs] in CmmBuildInfoTables, specifically
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment