Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 extern "C" {
      3   extern "C" void f(int);
      4 }
      5 
      6 extern "C++" {
      7   extern "C++" int& g(int);
      8   float& g();
      9 }
     10 double& g(double);
     11 
     12 void test(int x, double d) {
     13   f(x);
     14   float &f1 = g();
     15   int& i1 = g(x);
     16   double& d1 = g(d);
     17 }
     18 
     19 extern "C" int foo;
     20 extern "C" int foo;
     21 
     22 extern "C" const int bar;
     23 extern "C" int const bar;
     24 
     25 // <rdar://problem/6895431>
     26 extern "C" struct bar d;
     27 extern struct bar e;
     28 
     29 extern "C++" {
     30   namespace N0 {
     31     struct X0 {
     32       int foo(int x) { return x; }
     33     };
     34   }
     35 }
     36 
     37 // PR5430
     38 namespace pr5430 {
     39   extern "C" void func(void);
     40 }
     41 using namespace pr5430;
     42 extern "C" void pr5430::func(void) { }
     43 
     44 // PR5405
     45 int f2(char *)
     46 {
     47         return 0;
     48 }
     49 
     50 extern "C"
     51 {
     52     int f2(int)
     53     {
     54         return f2((char *)0);
     55     }
     56 }
     57 
     58 namespace PR5405 {
     59   int f2b(char *) {
     60     return 0;
     61   }
     62 
     63   extern "C" {
     64     int f2b(int) {
     65       return f2b((char *)0); // ok
     66     }
     67   }
     68 }
     69 
     70 // PR6991
     71 extern "C" typedef int (*PutcFunc_t)(int);
     72 
     73 
     74 // PR7859
     75 extern "C" void pr7859_a(int) {} // expected-note {{previous definition}}
     76 extern "C" void pr7859_a(int) {} // expected-error {{redefinition}}
     77 
     78 extern "C" void pr7859_b() {} // expected-note {{previous definition}}
     79 extern "C" void pr7859_b(int) {} // expected-error {{conflicting}}
     80 
     81 extern "C" void pr7859_c(short) {} // expected-note {{previous definition}}
     82 extern "C" void pr7859_c(int) {} // expected-error {{conflicting}}
     83 
     84 // <rdar://problem/8318976>
     85 extern "C" {
     86   struct s0 {
     87   private:
     88     s0();
     89     s0(const s0 &);
     90   };
     91 }
     92 
     93 //PR7754
     94 extern "C++" template <class T> int pr7754(T param);
     95 
     96 namespace N {
     97   int value;
     98 }
     99 
    100 extern "C++" using N::value;
    101 
    102 // PR7076
    103 extern "C" const char *Version_string = "2.9";
    104 
    105 extern "C" {
    106   extern const char *Version_string2 = "2.9";
    107 }
    108 
    109 namespace PR9162 {
    110   extern "C" {
    111     typedef struct _ArtsSink ArtsSink;
    112     struct _ArtsSink {
    113       int sink;
    114     };
    115   }
    116   int arts_sink_get_type()
    117   {
    118     return sizeof(ArtsSink);
    119   }
    120 }
    121 
    122 namespace pr14958 {
    123   namespace js { extern int ObjectClass; }
    124   extern "C" {
    125     namespace js {}
    126   }
    127   int js::ObjectClass;
    128 }
    129 
    130 extern "C" void PR16167; // expected-error {{variable has incomplete type 'void'}}
    131 extern void PR16167_0; // expected-error {{variable has incomplete type 'void'}}
    132 
    133 // PR7927
    134 enum T_7927 {
    135   E_7927
    136 };
    137 
    138 extern "C" void f_pr7927(int);
    139 
    140 namespace {
    141   extern "C" void f_pr7927(int);
    142 
    143   void foo_pr7927() {
    144     f_pr7927(E_7927);
    145     f_pr7927(0);
    146     ::f_pr7927(E_7927);
    147     ::f_pr7927(0);
    148   }
    149 }
    150 
    151 void bar_pr7927() {
    152   f_pr7927(E_7927);
    153   f_pr7927(0);
    154   ::f_pr7927(E_7927);
    155   ::f_pr7927(0);
    156 }
    157