decl-in-prototype.c revision 16f1f717af196b1448258857b2e6dcfe144b39d0
116f1f717af196b1448258857b2e6dcfe144b39d0James Molloy// RUN: %clang_cc1_only -verify %s
216f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
316f1f717af196b1448258857b2e6dcfe144b39d0James Molloyconst int AA = 5;
416f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
516f1f717af196b1448258857b2e6dcfe144b39d0James Molloyint f1(enum {AA,BB} E) {
616f1f717af196b1448258857b2e6dcfe144b39d0James Molloy    return BB;
716f1f717af196b1448258857b2e6dcfe144b39d0James Molloy}
816f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
916f1f717af196b1448258857b2e6dcfe144b39d0James Molloyint f2(enum {AA=7,BB} E) {
1016f1f717af196b1448258857b2e6dcfe144b39d0James Molloy    return AA;
1116f1f717af196b1448258857b2e6dcfe144b39d0James Molloy}
1216f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
1316f1f717af196b1448258857b2e6dcfe144b39d0James Molloystruct a {
1416f1f717af196b1448258857b2e6dcfe144b39d0James Molloy};
1516f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
1616f1f717af196b1448258857b2e6dcfe144b39d0James Molloyint f3(struct a { } *); // expected-warning {{will not be visible outside of this function}}
1716f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
1816f1f717af196b1448258857b2e6dcfe144b39d0James Molloystruct A { struct b { int j; } t; }; // expected-note {{previous definition is here}}
1916f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
2016f1f717af196b1448258857b2e6dcfe144b39d0James Molloyint f4(struct A { struct b { int j; } t; } *); // expected-warning {{declaration of 'struct A' will not be visible outside of this function}} expected-warning {{redefinition of 'b' will not be visible outside of this function}}
2116f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
2216f1f717af196b1448258857b2e6dcfe144b39d0James Molloystruct aA {
2316f1f717af196b1448258857b2e6dcfe144b39d0James Molloy    struct ab { // expected-note {{previous definition is here}} expected-note {{previous definition is here}}
2416f1f717af196b1448258857b2e6dcfe144b39d0James Molloy        int j;
2516f1f717af196b1448258857b2e6dcfe144b39d0James Molloy    } b;
2616f1f717af196b1448258857b2e6dcfe144b39d0James Molloy};
2716f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
2816f1f717af196b1448258857b2e6dcfe144b39d0James Molloyint f5(struct aA { struct ab { int j; } b; struct ab { char glorx; } glorx; } *); // expected-warning {{declaration of 'struct aA' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}} expected-warning {{redefinition of 'ab' will not be visible}}
2916f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
3016f1f717af196b1448258857b2e6dcfe144b39d0James Molloyvoid f6(struct z {int b;} c) { // expected-warning {{declaration of 'struct z' will not be visible outside of this function}}
3116f1f717af196b1448258857b2e6dcfe144b39d0James Molloy    struct z d;
3216f1f717af196b1448258857b2e6dcfe144b39d0James Molloy    d.b = 4;
3316f1f717af196b1448258857b2e6dcfe144b39d0James Molloy}
34