File: var-redecl.c

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (70 lines) | stat: -rw-r--r-- 2,909 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// RUN: %clang_cc1 -fsyntax-only -verify %s

int outer1; // expected-note{{previous definition is here}}
extern int outer2; // expected-note{{previous declaration is here}}
int outer4;
int outer4; // expected-note{{previous definition is here}}
int outer5;
int outer6(float); // expected-note{{previous definition is here}}
int outer7(float);

void outer_test(void) {
  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}}
  double outer4;
  extern int outer5; // expected-note{{previous declaration is here}}
  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;
  {
    extern int outer9; // expected-note{{previous declaration is here}}
  }
}

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}}

extern int outer13; // expected-note{{previous declaration is here}}
void outer_shadowing_test(void) {
  extern int outer10;
  extern int outer11; // expected-note{{previous declaration is here}}
  extern int outer12; // expected-note{{previous declaration is here}}
  {
    float outer10;
    float outer11;
    float outer12;
    {
      extern int outer10; // okay
      extern float outer11; // expected-error{{redeclaration of 'outer11' with a different type}}
      static double outer12;
      {
        extern float outer12; // expected-error{{redeclaration of 'outer12' with a different type}}
        extern float outer13; // expected-error{{redeclaration of 'outer13' with a different type}}
      }
    }
  }
}

void g18(void) { // expected-note{{'g18' declared here}}
  extern int g19;
}
int *p=&g19; // expected-error{{use of undeclared identifier 'g19'}} \
             // expected-warning{{incompatible pointer types}}

// PR3645
static int a;
extern int a; // expected-note {{previous declaration is here}}
int a;	// expected-error {{non-static declaration of 'a' follows static declaration}}

void f(int x) { // expected-note {{previous definition is here}}
  extern int x; // expected-error {{extern declaration of 'x' follows non-extern declaration}}
}

extern int b[];
void g20(void) { extern int b[3]; } // expected-note{{previous declaration is here}}
void g21(void) { extern int b[4]; } // expected-error{{redeclaration of 'b' with a different type: 'int[4]' vs 'int[3]'}}