Стандарт языка Си С99 TC (1113411), страница 17
Текст из файла (страница 17)
digitpp-numberpp-numberpp-numberpp-numberpp-numberpp-numberpp-numberdigitidentifier-nondigite signE signp signP sign.Description2A preprocessing number begins with a digit optionally preceded by a period (.) and maybe followed by valid identifier characters and the character sequences e+, e-, E+, E-,p+, p-, P+, or P-.3Preprocessing number tokens lexically include all floating and integer constant tokens.Semantics4A preprocessing number does not have type or a value; it acquires both after a successfulconversion (as part of translation phase 7) to a floating constant token or an integerconstant token.69) Thus, sequences of characters that resemble escape sequences cause undefined behavior.70) For an example of a header name preprocessing token used in a #pragma directive, see 6.10.9.§6.4.8Language65ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12566.4.9 Comments1Except within a character constant, a string literal, or a comment, the characters /*introduce a comment.
The contents of such a comment are examined only to identifymultibyte characters and to find the characters */ that terminate it.71)2Except within a character constant, a string literal, or a comment, the characters //introduce a comment that includes all multibyte characters up to, but not including, thenext new-line character. The contents of such a comment are examined only to identifymultibyte characters and to find the terminating new-line character.3EXAMPLE"a//b"#include "//e"// */f = g/**//h;//\i();/\/ j();#define glue(x,y) x##yglue(/,/) k();/*//*/ l();m = n//**/o+ p;////////four-character string literalundefined behaviorcomment, not syntax errorequivalent to f = g / h;// part of a two-line comment// part of a two-line comment// syntax error, not comment// equivalent to l();// equivalent to m = n + p;71) Thus, /* ...
*/ comments do not nest.66Language§6.4.9WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC36.5 Expressions1An expression is a sequence of operators and operands that specifies computation of avalue, or that designates an object or a function, or that generates side effects, or thatperforms a combination thereof.2Between the previous and next sequence point an object shall have its stored valuemodified at most once by the evaluation of an expression.72) Furthermore, the prior valueshall be read only to determine the value to be stored.73)3The grouping of operators and operands is indicated by the syntax.74) Except as specifiedlater (for the function-call (), &&, ||, ?:, and comma operators), the order of evaluationof subexpressions and the order in which side effects take place are both unspecified.4Some operators (the unary operator ~, and the binary operators <<, >>, &, ^, and |,collectively described as bitwise operators) are required to have operands that haveinteger type.
These operators yield values that depend on the internal representations ofintegers, and have implementation-defined and undefined aspects for signed types.5If an exceptional condition occurs during the evaluation of an expression (that is, if theresult is not mathematically defined or not in the range of representable values for itstype), the behavior is undefined.6The effective type of an object for an access to its stored value is the declared type of theobject, if any.75) If a value is stored into an object having no declared type through anlvalue having a type that is not a character type, then the type of the lvalue becomes the72) A floating-point status flag is not an object and can be set more than once within an expression.73) This paragraph renders undefined statement expressions such asi = ++i + 1;a[i++] = i;while allowingi = i + 1;a[i] = i;74) The syntax specifies the precedence of operators in the evaluation of an expression, which is the sameas the order of the major subclauses of this subclause, highest precedence first.
Thus, for example, theexpressions allowed as the operands of the binary + operator (6.5.6) are those expressions defined in6.5.1 through 6.5.6. The exceptions are cast expressions (6.5.4) as operands of unary operators(6.5.3), and an operand contained between any of the following pairs of operators: groupingparentheses () (6.5.1), subscripting brackets [] (6.5.2.1), function-call parentheses () (6.5.2.2), andthe conditional operator ?: (6.5.15).Within each major subclause, the operators have the same precedence.
Left- or right-associativity isindicated in each subclause by the syntax for the expressions discussed therein.75) Allocated objects have no declared type.§6.5Language67ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256effective type of the object for that access and for subsequent accesses that do not modifythe stored value. If a value is copied into an object having no declared type usingmemcpy or memmove, or is copied as an array of character type, then the effective typeof the modified object for that access and for subsequent accesses that do not modify thevalue is the effective type of the object from which the value is copied, if it has one.
Forall other accesses to an object having no declared type, the effective type of the object issimply the type of the lvalue used for the access.7An object shall have its stored value accessed only by an lvalue expression that has one ofthe following types:76)— a type compatible with the effective type of the object,— a qualified version of a type compatible with the effective type of the object,— a type that is the signed or unsigned type corresponding to the effective type of theobject,— a type that is the signed or unsigned type corresponding to a qualified version of theeffective type of the object,— an aggregate or union type that includes one of the aforementioned types among itsmembers (including, recursively, a member of a subaggregate or contained union), or— a character type.8A floating expression may be contracted, that is, evaluated as though it were an atomicoperation, thereby omitting rounding errors implied by the source code and theexpression evaluation method.77) The FP_CONTRACT pragma in <math.h> provides away to disallow contracted expressions.
Otherwise, whether and how expressions arecontracted is implementation-defined.78)Forward references: the FP_CONTRACT pragma (7.12.2), copying functions (7.21.2).76) The intent of this list is to specify those circumstances in which an object may or may not be aliased.77) A contracted expression might also omit the raising of floating-point exceptions.78) This license is specifically intended to allow implementations to exploit fast machine instructions thatcombine multiple C operators.
As contractions potentially undermine predictability, and can evendecrease accuracy for containing expressions, their use needs to be well-defined and clearlydocumented.68Language§6.5WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC36.5.1 Primary expressionsSyntax1primary-expression:identifierconstantstring-literal( expression )Semantics2An identifier is a primary expression, provided it has been declared as designating anobject (in which case it is an lvalue) or a function (in which case it is a functiondesignator).79)3A constant is a primary expression.
Its type depends on its form and value, as detailed in6.4.4.4A string literal is a primary expression. It is an lvalue with type as detailed in 6.4.5.5A parenthesized expression is a primary expression. Its type and value are identical tothose of the unparenthesized expression. It is an lvalue, a function designator, or a voidexpression if the unparenthesized expression is, respectively, an lvalue, a functiondesignator, or a void expression.Forward references: declarations (6.7).6.5.2 Postfix operatorsSyntax1postfix-expression:primary-expressionpostfix-expression [ expression ]postfix-expression ( argument-expression-listopt )postfix-expression . identifierpostfix-expression -> identifierpostfix-expression ++postfix-expression -( type-name ) { initializer-list }( type-name ) { initializer-list , }79) Thus, an undeclared identifier is a violation of the syntax.§6.5.2Language69ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256argument-expression-list:assignment-expressionargument-expression-list , assignment-expression6.5.2.1 Array subscriptingConstraints1One of the expressions shall have type ‘‘pointer to object type’’, the other expression shallhave integer type, and the result has type ‘‘type’’.Semantics2A postfix expression followed by an expression in square brackets [] is a subscripteddesignation of an element of an array object.
The definition of the subscript operator []is that E1[E2] is identical to (*((E1)+(E2))). Because of the conversion rules thatapply to the binary + operator, if E1 is an array object (equivalently, a pointer to theinitial element of an array object) and E2 is an integer, E1[E2] designates the E2-thelement of E1 (counting from zero).3Successive subscript operators designate an element of a multidimensional array object.If E is an n-dimensional array (n ≥ 2) with dimensions i × j × . . . × k, then E (used asother than an lvalue) is converted to a pointer to an (n − 1)-dimensional array withdimensions j × . . .
× k. If the unary * operator is applied to this pointer explicitly, orimplicitly as a result of subscripting, the result is the pointed-to (n − 1)-dimensional array,which itself is converted into a pointer if used as other than an lvalue. It follows from thisthat arrays are stored in row-major order (last subscript varies fastest).4EXAMPLEConsider the array object defined by the declarationint x[3][5];Here x is a 3 × 5 array of ints; more precisely, x is an array of three element objects, each of which is anarray of five ints.