brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · d6241a4 Raw
41 lines · c
1// RUN: %clang_cc1 -E -verify %s2 3// C++ [lex.icon]p4 and C 6.4.4.1p2 + 6.4.4.2p7 both require C and C++ to4// validate the integer constant value when converting a preprocessing token5// into a token for semantic analysis, even within the preprocessor itself.6 7// Plain integer constant.8#if 999999999999999999999 // expected-error {{integer literal is too large to be represented in any integer type}}9#endif10 11// These cases were previously incorrectly accepted. See GH134658.12 13// Integer constant in an unevaluated branch of a conditional.14#if 1 ? 1 : 999999999999999999999 // expected-error {{integer literal is too large to be represented in any integer type}}15#endif16 17// Integer constant in an unevaluated operand of a logical operator.18#if 0 && 999999999999999999999 // expected-error {{integer literal is too large to be represented in any integer type}}19#endif20 21#if 1 || 999999999999999999999 // expected-error {{integer literal is too large to be represented in any integer type}}22#endif23 24// Make sure we also catch it in an elif condition.25#if 026#elif 1 || 999999999999999999999 // expected-error {{integer literal is too large to be represented in any integer type}}27#endif28 29// However, if the block is skipped entirely, then it doesn't matter how30// invalid the constant value is.31#if 032int x = 999999999999999999999;33 34#if 99999999999999999999935#endif36 37#if 0 && 99999999999999999999938#endif39 40#endif41