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