1d25db7edSJohn McCall // RUN: %clang_cc1 -fsyntax-only -verify %s 2d25db7edSJohn McCall 3d25db7edSJohn McCall struct A { 4d25db7edSJohn McCall unsigned bitX : 4; 5d25db7edSJohn McCall unsigned bitY : 4; 6d25db7edSJohn McCall unsigned var; 7d25db7edSJohn McCall 8d25db7edSJohn McCall void foo(); 9d25db7edSJohn McCall }; 10d25db7edSJohn McCall test(A * a)11d25db7edSJohn McCallvoid test(A *a) { 12d25db7edSJohn McCall int x; 13d25db7edSJohn McCall x = sizeof(a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} 14d25db7edSJohn McCall x = sizeof((unsigned) a->bitX); 15d25db7edSJohn McCall x = sizeof(a->foo(), a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} 16d25db7edSJohn McCall x = sizeof(a->var ? a->bitX : a->bitY); // expected-error {{invalid application of 'sizeof' to bit-field}} 17d25db7edSJohn McCall x = sizeof(a->var ? a->bitX : a->bitX); // expected-error {{invalid application of 'sizeof' to bit-field}} 18d25db7edSJohn McCall x = sizeof(a->bitX = 3); // expected-error {{invalid application of 'sizeof' to bit-field}} 19d25db7edSJohn McCall x = sizeof(a->bitY += 3); // expected-error {{invalid application of 'sizeof' to bit-field}} 20d25db7edSJohn McCall } 214e28b265SEli Friedman test2()224e28b265SEli Friedmanvoid test2() { 234e28b265SEli Friedman int x; 244e28b265SEli Friedman x = sizeof(void); // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}} 254e28b265SEli Friedman x = sizeof(int()); // expected-error {{invalid application of 'sizeof' to a function type}} 264e28b265SEli Friedman x = sizeof(test2()); // expected-error {{invalid application of 'sizeof' to an incomplete type 'void'}} 274e28b265SEli Friedman x = sizeof(test2); // expected-error {{invalid application of 'sizeof' to a function type}} 284e28b265SEli Friedman } 29aa57a64eSSerge Pavlov 30aa57a64eSSerge Pavlov namespace pr16992 { 31aa57a64eSSerge Pavlov 32aa57a64eSSerge Pavlov template<typename T> struct ABC { funcpr16992::ABC33aa57a64eSSerge Pavlov int func () { 34*767c1f84SDavid Majnemer return sizeof T; // expected-error {{expected parentheses around type name in sizeof expression}} 35aa57a64eSSerge Pavlov } 36aa57a64eSSerge Pavlov }; 37aa57a64eSSerge Pavlov 38aa57a64eSSerge Pavlov ABC<int> qq; 39aa57a64eSSerge Pavlov 40aa57a64eSSerge Pavlov template<typename T> struct ABC2 { funcpr16992::ABC241aa57a64eSSerge Pavlov int func () { 42aa57a64eSSerge Pavlov return sizeof T::A; 43aa57a64eSSerge Pavlov } 44aa57a64eSSerge Pavlov }; 45aa57a64eSSerge Pavlov 46aa57a64eSSerge Pavlov struct QQ { int A; }; 47aa57a64eSSerge Pavlov ABC2<QQ> qq2; 48aa57a64eSSerge Pavlov } 49