mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 21:46:05 +00:00

DR2338 clarified that it was undefined behavior to set the value outside the range of the enumerations values for an enum without a fixed underlying type. We should diagnose this with a constant expression context. Differential Revision: https://reviews.llvm.org/D130058
25 lines
508 B
C++
25 lines
508 B
C++
// RUN: %clang_cc1 -fsyntax-only -ast-print %s | FileCheck %s
|
|
|
|
namespace NamedEnumNS
|
|
{
|
|
|
|
enum class NamedEnum
|
|
{
|
|
Val0,
|
|
Val1
|
|
};
|
|
|
|
template <NamedEnum E>
|
|
void foo();
|
|
|
|
void test() {
|
|
// CHECK: template<> void foo<NamedEnumNS::NamedEnum::Val0>()
|
|
NamedEnumNS::foo<NamedEnum::Val0>();
|
|
// CHECK: template<> void foo<NamedEnumNS::NamedEnum::Val1>()
|
|
NamedEnumNS::foo<(NamedEnum)1>();
|
|
// CHECK: template<> void foo<(NamedEnumNS::NamedEnum)2>()
|
|
NamedEnumNS::foo<(NamedEnum)2>();
|
|
}
|
|
|
|
} // NamedEnumNS
|