Skip to content

Commit c4b9b88

Browse files
authored
Add language about bit-fields (#743)
Add language about conversions to and from bit-fields.
1 parent f417dc1 commit c4b9b88

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

specs/language/classes.tex

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
\Ch{Classes}{Classes}
2+
\Sec{Bit-field}{Classes.Bitfield}
3+
\p A bit-field is a class member with an explicit size specified in bits. Bit-fields must be of an underflying integer type.
4+
\begin{HLSL}
5+
struct Foo {
6+
uint A : 10;
7+
bool B : 1;
8+
};
9+
\end{HLSL}
10+
\p A bit-field can be unnamed. Unnamed bit-fields cannot be accessed or initialized.
11+
\begin{HLSL}
12+
struct Foo {
13+
uint : 10;
14+
};
15+
\end{HLSL}
16+
\p The explicit size of a named bit-field must be a constant expression of integer type, and must resolve to a number greater than zero and less than or equal to the size of the specified type in bits.
17+
\p The explicit size of an unnamed bit-field can also be zero.
18+
\p A bit-field cannot be a static member.
19+
\Sec{Static Members}{Classes.Static}
20+
\Sec{Conversions}{Classes.Conversions}

specs/language/conversions.tex

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
\p If the glvalue refers to an array of type \texttt{T}, the prvalue will refer
3232
to a copy of the array, not memory referred to by the glvalue.
3333

34+
\p If the glvalue refers to a bit-field of type \texttt{T}, the conversion
35+
produces an object of the underlying type of the bit-field.
36+
3437
\Sec{Array-to-pointer conversion}{Conv.array}
3538

3639
\p An lvalue or rvalue of type \texttt{T[]} (unsized array), can be converted to
@@ -85,6 +88,12 @@
8588
\p If the source type is \texttt{bool}, the values \texttt{true} and
8689
\texttt{false} are converted to one and zero respectively.
8790

91+
\Sec{Bit-field conversion}{Conv.bitfield}
92+
93+
\p A glvalue of a named bit-field with underlying integer type \texttt{T} can be
94+
converted to a cxvalue of type \texttt{T$^\prime$} if there exists an implicit
95+
conversion from \texttt{T} to \texttt{T$^\prime$}.
96+
8897
\Sec{Floating point conversion}{Conv.fconv}
8998

9099
\p A glvalue of a floating point type can be converted to a cxvalue of any other

specs/language/placeholders.tex

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
% forward references can be inserted into the specification as it is being
55
% written to force updating the references as they change.
66

7-
\Ch{Classes}{Classes}
8-
\Sec{Static Members}{Classes.Static}
9-
\Sec{Conversions}{Classes.Conversions}
107
\Ch{Templates}{Template}
118
\Sec{Template Instantiation}{Template.Inst}
129
\Sec{Partial Ordering of Function Templates}{Template.Func.Order}

0 commit comments

Comments
 (0)