brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · e1cb41f Raw
46 lines · c
1// RUN: %clang_cc1 -verify -std=c2y -Wall -pedantic -Wno-unused %s2 3/* WG14 N3410: No4 * Slay Some Earthly Demons XI5 *6 * It is now ill-formed for the same identifier within a TU to have both7 * internal and external linkage.8 */9 10void func1() {11  extern int a; // #a12}13 14// This 'a' is the same as the one declared extern above.15static int a; /* expected-error {{static declaration of 'a' follows non-static declaration}}16                 expected-note@#a {{previous declaration is here}}17               */18 19static int b;20void func2() {21  // This 'b' is the same as the one declaraed static above, but this is not22  // ill-formed because of C2y 6.2.2p4, which gives this variable internal23  // linkage because the previous declaration had internal linkage.24  extern int b; // Ok25}26 27static int c, d;28void func3() {29  int c; // no linkage, different object from the one declared above.30  for (int d;;) {31    // This 'c' is the same as the one declared at file scope, but because of32    // the local scope 'c', the file scope 'c' is not visible.33    // FIXME: This should be diagnosed under N3410.34    extern int c;35    // This 'd' is the same as the one declared at file scope as well, but36    // because of the 'd' declared within the for loop, the file scope 'd' is37    // also not visible, same as with 'c'.38    // FIXME: This should be diagnosed under N3410.39    extern int d;40  }41  for (static int e;;) {42    extern int e; // Ok for the same reason as 'b' above.43  }44}45 46