// ---------------------------------------------------------------------- // // forok.cc - ISOcxx test for old 'for' scoping rules: // // A variable defined inside a for loop should be in the scope of the // loop. It should not conflict with any previously-defined entity of // the same name, nor should it any longer be defined after loop // termination. // // History: // 31-May-1999 WEB Adapt from previous incarnation // 02-Jun-1999 WEB Incorporate ISOcxx/syntax.h header to simplify // validation // 07-Jun-1999 WEB Introduce START // 18-Jun-1999 WEB Adopt new name for compliance header // 25-Apr-2001 WEB s//"ISOcxx\/ISOcxxSyntax.hh"/ // // ---------------------------------------------------------------------- #include "ISOcxx/ISOcxxSyntax.hh" int const START( -2 ); int main() { int i( START ); int sum( 0 ); for ( int i( 0 ); i < 10; ++i ) { // a new i; ought compile ok sum += i; } return ( i == START ) ? 0 : 1; // original i; ought be unchanged } // main()