1f08c3bdfSopenharmony_cistatic int bad_scope(void) 2f08c3bdfSopenharmony_ci{ 3f08c3bdfSopenharmony_ci int r = 0; 4f08c3bdfSopenharmony_ci 5f08c3bdfSopenharmony_ci for (int i = 0; i < 10; i++) { 6f08c3bdfSopenharmony_ci r = i; 7f08c3bdfSopenharmony_ci } 8f08c3bdfSopenharmony_ci 9f08c3bdfSopenharmony_ci return i; /* check-should-fail */ 10f08c3bdfSopenharmony_ci} 11f08c3bdfSopenharmony_ci 12f08c3bdfSopenharmony_cistatic int c99(void) 13f08c3bdfSopenharmony_ci{ 14f08c3bdfSopenharmony_ci int r = 0; 15f08c3bdfSopenharmony_ci 16f08c3bdfSopenharmony_ci for ( int i = 0; i < 10; i++) /* check-should-pass */ 17f08c3bdfSopenharmony_ci r = i; 18f08c3bdfSopenharmony_ci for ( auto int j = 0; j < 10; j++) /* check-should-pass */ 19f08c3bdfSopenharmony_ci r = j; 20f08c3bdfSopenharmony_ci for (register int k = 0; k < 10; k++) /* check-should-pass */ 21f08c3bdfSopenharmony_ci r = k; 22f08c3bdfSopenharmony_ci for ( extern int l = 0; l < 10; l++) /* check-should-fail */ 23f08c3bdfSopenharmony_ci r = l; 24f08c3bdfSopenharmony_ci for ( extern int m; m < 10; m++) /* check-should-fail */ 25f08c3bdfSopenharmony_ci r = m; 26f08c3bdfSopenharmony_ci for ( static int n = 0; n < 10; n++) /* check-should-fail */ 27f08c3bdfSopenharmony_ci r = n; 28f08c3bdfSopenharmony_ci return r; 29f08c3bdfSopenharmony_ci} 30f08c3bdfSopenharmony_ci 31f08c3bdfSopenharmony_ci/* 32f08c3bdfSopenharmony_ci * check-name: C99 for-loop declarations 33f08c3bdfSopenharmony_ci * 34f08c3bdfSopenharmony_ci * check-error-start 35f08c3bdfSopenharmony_cic99-for-loop-decl.c:22:27: error: non-local var 'l' in for-loop initializer 36f08c3bdfSopenharmony_cic99-for-loop-decl.c:24:27: error: non-local var 'm' in for-loop initializer 37f08c3bdfSopenharmony_cic99-for-loop-decl.c:26:27: error: non-local var 'n' in for-loop initializer 38f08c3bdfSopenharmony_cic99-for-loop-decl.c:9:16: error: undefined identifier 'i' 39f08c3bdfSopenharmony_ci * check-error-end 40f08c3bdfSopenharmony_ci */ 41