1651f13cea278ec967336033dd032faef0e9fc2ecStephen Hines// RUN: %clang_cc1 -fsyntax-only -verify %s
216f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
316f1f717af196b1448258857b2e6dcfe144b39d0James Molloyconst int AA = 5;
416f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
5651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesint f1(enum {AA,BB} E) { // expected-warning {{will not be visible outside of this function}}
616f1f717af196b1448258857b2e6dcfe144b39d0James Molloy    return BB;
716f1f717af196b1448258857b2e6dcfe144b39d0James Molloy}
816f1f717af196b1448258857b2e6dcfe144b39d0James Molloy
9651f13cea278ec967336033dd032faef0e9fc2ecStephen Hinesint f2(enum {AA=7,BB} E) { // expected-warning {{will not be visible outside of this function}}
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}
34c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines
35c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hinesvoid pr19018_1 (enum e19018 { qq } x); // expected-warning{{declaration of 'enum e19018' will not be visible outside of this function}}
36c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hinesenum e19018 qq; //expected-error{{tentative definition has type 'enum e19018' that is never completed}} \
37c568f1e98938584c0ef0b12ae5018ff7d90a4072Stephen Hines                //expected-note{{forward declaration of 'enum e19018'}}
38