view gcc/testsuite/g++.dg/ext/offsetof1.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// PR c++/27601
// Origin: Patrik Hägglund  <patrik.hagglund@bredband.net>
// { dg-do compile }
// { dg-options "-Wno-pointer-arith" }

struct bar {
  static int foo;
  static int baz();
};

int a = __builtin_offsetof(bar, foo);  // { dg-error "static data member" }
int av = __builtin_offsetof(volatile bar, foo);  // { dg-error "static data member" }
int b = __builtin_offsetof(bar, baz);  // { dg-error "member function" }
int b0 = __builtin_offsetof(bar, baz[0]);  // { dg-error "single identifier nor|member function" }
int bv0 = __builtin_offsetof(volatile bar, baz[0]);  // { dg-error "function" }
int c = __builtin_offsetof(bar, ~bar);  // { dg-error "member function" }

typedef int I;
enum E { };

int d = __builtin_offsetof(I, ~I);  // { dg-error "destructor" }
int e = __builtin_offsetof(E, ~E);  // { dg-error "destructor" }