1 // RUN: %clang_cc1 %s -verify 2 3 // expected-no-diagnostics 4 5 namespace PromotionVersusMutation { 6 typedef unsigned Unsigned; 7 typedef signed Signed; 8 9 struct T { unsigned n : 2; } t; 10 11 typedef __typeof__(t.n) Unsigned; // Bitfield is unsigned 12 typedef __typeof__(+t.n) Signed; // ... but promotes to signed. 13 14 typedef __typeof__(t.n + 0) Signed; // Arithmetic promotes. 15 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; 22 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; 27 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). 32 } 33