view gcc/testsuite/g++.dg/cpp0x/enum_base.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

// { dg-do compile { target c++11 } }

typedef unsigned volatile long long uvlonglong;

enum E1 : char { };
enum E2 : signed const short { };
enum E3 : uvlonglong { };
enum E4 : char { 
  val = 500 // { dg-error "outside the range" }
};

enum class E5 {
  val = (unsigned long long)-1 // { dg-error "outside the range" }
};

typedef float Float;

enum class E6 : Float { }; // { dg-error "must be an integral type" }

static_assert (sizeof(E1) == sizeof(char), "char-sized enum");
static_assert (sizeof(E2) == sizeof(signed short), "short-sized enum"); 
static_assert (sizeof(E3) == sizeof(unsigned long long), 
               "long long-sized enum"); 
static_assert (sizeof(E4) == sizeof(char), "char-sized enum");
static_assert (sizeof(E5) == sizeof(int), "scoped enum with int size");