1 // RUN: %clang_cc1 %s -verify
3 // expected-no-diagnostics
5 namespace PromotionVersusMutation
{
6 typedef unsigned Unsigned
;
9 struct T
{ unsigned n
: 2; } t
;
11 typedef __typeof__(t
.n
) Unsigned
; // Bitfield is unsigned
12 typedef __typeof__(+t
.n
) Signed
; // ... but promotes to signed.
14 typedef __typeof__(t
.n
+ 0) Signed
; // Arithmetic promotes.
16 typedef __typeof__(t
.n
= 0) Unsigned
; // Assignment produces an lvalue...
17 typedef __typeof__(t
.n
+= 0) Unsigned
;
18 typedef __typeof__(t
.n
*= 0) Unsigned
;
19 typedef __typeof__(+(t
.n
= 0)) Signed
; // ... which is a bit-field.
20 typedef __typeof__(+(t
.n
+= 0)) Signed
;
21 typedef __typeof__(+(t
.n
*= 0)) Signed
;
23 typedef __typeof__(++t
.n
) Unsigned
; // Increment is equivalent to compound-assignment.
24 typedef __typeof__(--t
.n
) Unsigned
;
25 typedef __typeof__(+(++t
.n
)) Signed
;
26 typedef __typeof__(+(--t
.n
)) Signed
;
28 typedef __typeof__(t
.n
++) Unsigned
; // Post-increment's result has the type
29 typedef __typeof__(t
.n
--) Unsigned
; // of the operand...
30 typedef __typeof__(+(t
.n
++)) Unsigned
; // ... and is not a bit-field (because
31 typedef __typeof__(+(t
.n
--)) Unsigned
; // it's not a glvalue).