Skip to content

Commit ecc4fd7

Browse files
committed
Add mask
1 parent 9639fe9 commit ecc4fd7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

flang/include/flang/ISO_Fortran_binding.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ extern "C++" template <typename T> struct FlexibleArray : T {
154154
#define _CFI_ADDENDUM_BITS 1
155155
/* Value of the addendum presence flag */
156156
#define _CFI_ADDENDUM_FLAG 1
157+
/* Allocator index mask */
158+
#define _CFI_ALLOCATOR_IDX_MASK 0b00001110
157159

158160
typedef struct CFI_cdesc_t {
159161
_CFI_CDESC_T_HEADER_MEMBERS
@@ -169,9 +171,10 @@ typedef struct CFI_cdesc_t {
169171
}
170172
RT_API_ATTRS inline void SetHasAddendum() { extra |= _CFI_ADDENDUM_FLAG; }
171173
RT_API_ATTRS inline int GetAllocIdx() const {
172-
return ((int)extra >> _CFI_ADDENDUM_BITS);
174+
return (extra & _CFI_ALLOCATOR_IDX_MASK) >> _CFI_ADDENDUM_BITS;
173175
}
174176
RT_API_ATTRS inline void SetAllocIdx(int pos) {
177+
extra &= ~_CFI_ALLOCATOR_IDX_MASK; // Clear the allocator index bits.
175178
extra |= (pos << _CFI_ADDENDUM_BITS);
176179
}
177180
#endif

0 commit comments

Comments
 (0)