Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -19690,14 +19690,24 @@ BestPromotionType = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus) ? Context.UnsignedLongTy : Context.LongTy; - } else { + } else if (NumPositiveBits <= Context.getTargetInfo().getLongLongWidth()) { BestWidth = Context.getTargetInfo().getLongLongWidth(); - assert(NumPositiveBits <= BestWidth && - "How could an initializer get larger than ULL?"); BestType = Context.UnsignedLongLongTy; BestPromotionType = (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus) ? Context.UnsignedLongLongTy : Context.LongLongTy; + } else { + BestWidth = 128; + assert(NumPositiveBits <= BestWidth && + "How could an initializer get larger than 128-bit?"); + assert(Context.getTargetInfo().hasInt128Type() && + "How could an initializer get larger than ULL in target without " + "128-bit interger type support?"); + BestType = Context.UnsignedInt128Ty; + BestPromotionType = + (NumPositiveBits == BestWidth || !getLangOpts().CPlusPlus) + ? Context.UnsignedInt128Ty + : Context.Int128Ty; } } Index: clang/test/Sema/enum.c =================================================================== --- clang/test/Sema/enum.c +++ clang/test/Sema/enum.c @@ -1,4 +1,9 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple %s -fsyntax-only -verify -pedantic +enum b { + b0 = (__uint128_t)-1, // expected-warning {{ISO C restricts enumerator values to range of 'int'}} + b1 = (__uint128_t)0x123456789abcdef0ULL << 64|0x0fedcba987654321ULL, // expected-warning {{ISO C restricts enumerator values to range of 'int'}} +}; + enum e {A, B = 42LL << 32, // expected-warning {{ISO C restricts enumerator values to range of 'int'}} C = -4, D = 12456 };