Home | History | Annotate | Download | only in basic.link
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 // C++11 [basic.link]p6:
      4 //   The name of a function declared in block scope and the name
      5 //   of a variable declared by a block scope extern declaration
      6 //   have linkage. If there is a visible declaration of an entity
      7 //   with linkage having the same name and type, ignoring entities
      8 //   declared outside the innermost enclosing namespace scope, the
      9 //   block scope declaration declares that same entity and
     10 //   receives the linkage of the previous declaration.
     11 
     12 // rdar://13535367
     13 namespace test0 {
     14   extern "C" int test0_array[];
     15   void declare() { extern int test0_array[100]; }
     16   extern "C" int test0_array[];
     17   int value = sizeof(test0_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
     18 }
     19 
     20 namespace test1 {
     21   extern "C" int test1_array[];
     22   void test() {
     23     { extern int test1_array[100]; }
     24     extern int test1_array[];
     25     int x = sizeof(test1_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
     26   }
     27 }
     28 
     29 namespace test2 {
     30   void declare() { extern int test2_array[100]; }
     31   extern int test2_array[];
     32   int value = sizeof(test2_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
     33 }
     34 
     35 namespace test3 {
     36   void test() {
     37     { extern int test3_array[100]; }
     38     extern int test3_array[];
     39     int x = sizeof(test3_array); // expected-error {{invalid application of 'sizeof' to an incomplete type 'int []'}}
     40   }
     41 }
     42 
     43 
     44