brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 76c5a0b Raw
21 lines · c
1// RUN: %clang_cc1 -verify -std=c2y -finitial-counter-value=2147483646 %s2 3// The value produced needs to be a type that's representable with a signed4// long. However, the actual type it expands to does *not* need to be forced to5// be signed long because that would generally mean suffixing the value with L,6// which would be very surprising for folks using this to generate unique ids.7// We'll test this by ensuring the largest value can be expanded properly and8// an assertion that signed long is always at least four bytes wide (which is9// what's required to represent that maximal value).10//11// So we set the initial counter value to 2147483646, we'll validate that,12// increment it once to get to the maximal value and ensure there's no13// diagnostic, then increment again to ensure we get the constraint violation.14 15static_assert(__COUNTER__ == 2147483646); // Test and increment16static_assert(__COUNTER__ == 2147483647); // Test and increment17 18// This one should fail.19signed long i = __COUNTER__; // expected-error {{'__COUNTER__' value cannot exceed 2'147'483'647}}20 21