2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-02-25 03:23:27 +08:00
|
|
|
|
|
|
|
int outer1; // expected-note{{previous definition is here}}
|
2015-07-15 04:08:49 +08:00
|
|
|
extern int outer2; // expected-note{{previous declaration is here}}
|
2009-02-25 03:23:27 +08:00
|
|
|
int outer4;
|
|
|
|
int outer4; // expected-note{{previous definition is here}}
|
2015-01-14 10:27:38 +08:00
|
|
|
int outer5;
|
2009-02-25 03:23:27 +08:00
|
|
|
int outer6(float); // expected-note{{previous definition is here}}
|
|
|
|
int outer7(float);
|
|
|
|
|
|
|
|
void outer_test() {
|
2015-07-15 04:08:49 +08:00
|
|
|
extern float outer1; // expected-error{{redeclaration of 'outer1' with a different type}}
|
|
|
|
extern float outer2; // expected-error{{redeclaration of 'outer2' with a different type}}
|
|
|
|
extern float outer3; // expected-note{{previous declaration is here}}
|
2009-02-25 03:23:27 +08:00
|
|
|
double outer4;
|
2015-07-15 04:08:49 +08:00
|
|
|
extern int outer5; // expected-note{{previous declaration is here}}
|
2009-02-25 03:23:27 +08:00
|
|
|
extern int outer6; // expected-error{{redefinition of 'outer6' as different kind of symbol}}
|
|
|
|
int outer7;
|
|
|
|
extern int outer8; // expected-note{{previous definition is here}}
|
|
|
|
extern int outer9;
|
|
|
|
{
|
2015-07-15 04:08:49 +08:00
|
|
|
extern int outer9; // expected-note{{previous declaration is here}}
|
2009-02-25 03:23:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int outer3; // expected-error{{redefinition of 'outer3' with a different type}}
|
|
|
|
float outer4; // expected-error{{redefinition of 'outer4' with a different type}}
|
|
|
|
float outer5; // expected-error{{redefinition of 'outer5' with a different type}}
|
|
|
|
int outer8(int); // expected-error{{redefinition of 'outer8' as different kind of symbol}}
|
|
|
|
float outer9; // expected-error{{redefinition of 'outer9' with a different type}}
|
2009-02-25 04:03:32 +08:00
|
|
|
|
2015-07-15 04:08:49 +08:00
|
|
|
extern int outer13; // expected-note{{previous declaration is here}}
|
2009-02-25 04:03:32 +08:00
|
|
|
void outer_shadowing_test() {
|
|
|
|
extern int outer10;
|
2015-07-15 04:08:49 +08:00
|
|
|
extern int outer11; // expected-note{{previous declaration is here}}
|
|
|
|
extern int outer12; // expected-note{{previous declaration is here}}
|
2009-02-25 04:03:32 +08:00
|
|
|
{
|
|
|
|
float outer10;
|
|
|
|
float outer11;
|
|
|
|
float outer12;
|
|
|
|
{
|
|
|
|
extern int outer10; // okay
|
2015-07-15 04:08:49 +08:00
|
|
|
extern float outer11; // expected-error{{redeclaration of 'outer11' with a different type}}
|
2009-02-25 04:03:32 +08:00
|
|
|
static double outer12;
|
|
|
|
{
|
2015-07-15 04:08:49 +08:00
|
|
|
extern float outer12; // expected-error{{redeclaration of 'outer12' with a different type}}
|
|
|
|
extern float outer13; // expected-error{{redeclaration of 'outer13' with a different type}}
|
2009-02-25 04:03:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-03-02 08:19:53 +08:00
|
|
|
|
2010-01-07 08:17:44 +08:00
|
|
|
void g18(void) { // expected-note{{'g18' declared here}}
|
2009-03-02 08:19:53 +08:00
|
|
|
extern int g19;
|
|
|
|
}
|
2009-12-31 13:20:13 +08:00
|
|
|
int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \
|
|
|
|
// expected-warning{{incompatible pointer types}}
|
2009-03-20 06:01:50 +08:00
|
|
|
|
|
|
|
// PR3645
|
|
|
|
static int a;
|
2014-06-19 07:26:25 +08:00
|
|
|
extern int a; // expected-note {{previous declaration is here}}
|
2010-06-22 00:08:37 +08:00
|
|
|
int a; // expected-error {{non-static declaration of 'a' follows static declaration}}
|
2015-01-14 08:31:13 +08:00
|
|
|
|
|
|
|
void f(int x) { // expected-note {{previous definition is here}}
|
|
|
|
extern int x; // expected-error {{extern declaration of 'x' follows non-extern declaration}}
|
|
|
|
}
|
2015-01-14 10:27:38 +08:00
|
|
|
|
|
|
|
extern int b[];
|
2015-07-15 04:08:49 +08:00
|
|
|
void g20() { extern int b[3]; } // expected-note{{previous declaration is here}}
|
|
|
|
void g21() { extern int b[4]; } // expected-error{{redeclaration of 'b' with a different type: 'int [4]' vs 'int [3]'}}
|