31 lines · c
1/* RUN: %clang_cc1 -std=c89 -Wno-gcc-compat -ast-dump -o - %s | FileCheck %s2 RUN: %clang_cc1 -std=c99 -ast-dump -o - %s | FileCheck %s3 RUN: %clang_cc1 -std=c11 -ast-dump -o - %s | FileCheck %s4 RUN: %clang_cc1 -std=c17 -ast-dump -o - %s | FileCheck %s5 RUN: %clang_cc1 -std=c2x -ast-dump -o - %s | FileCheck %s6 */7 8/* WG14 DR466: yes9 * Scope of a for loop control declaration10 */11int dr466(void) {12 for (int i = 0; ; ) {13 long i = 1; /* valid C, invalid C++ */14 // ...15 return i; /* (perhaps unexpectedly) returns 1 in C */16 }17}18 19/*20CHECK: FunctionDecl 0x{{.+}} dr466 'int (void)'21CHECK-NEXT: CompoundStmt22CHECK-NEXT: ForStmt23CHECK-NEXT: DeclStmt24CHECK-NEXT: VarDecl 0x{{.+}} {{.+}} i 'int'25CHECK: CompoundStmt26CHECK-NEXT: DeclStmt27CHECK-NEXT: VarDecl [[ACTUAL:0x.+]] <col:{{.+}}> col:{{.+}} used i 'long'28CHECK: ReturnStmt29CHECK: DeclRefExpr 0x{{.+}} <col:{{.+}}> 'long' lvalue Var [[ACTUAL]] 'i' 'long'30*/31