2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2013-10-23 06:53:01 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wretained-language-linkage -DW_RETAINED_LANGUAGE_LINKAGE %s
|
2009-01-06 03:50:09 +08:00
|
|
|
extern "C" {
|
|
|
|
extern "C" void f(int);
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C++" {
|
|
|
|
extern "C++" int& g(int);
|
|
|
|
float& g();
|
|
|
|
}
|
|
|
|
double& g(double);
|
|
|
|
|
|
|
|
void test(int x, double d) {
|
|
|
|
f(x);
|
|
|
|
float &f1 = g();
|
|
|
|
int& i1 = g(x);
|
|
|
|
double& d1 = g(d);
|
|
|
|
}
|
2009-01-07 10:48:43 +08:00
|
|
|
|
|
|
|
extern "C" int foo;
|
|
|
|
extern "C" int foo;
|
|
|
|
|
|
|
|
extern "C" const int bar;
|
|
|
|
extern "C" int const bar;
|
2009-05-17 06:05:23 +08:00
|
|
|
|
|
|
|
// <rdar://problem/6895431>
|
|
|
|
extern "C" struct bar d;
|
|
|
|
extern struct bar e;
|
2009-08-25 02:55:03 +08:00
|
|
|
|
|
|
|
extern "C++" {
|
|
|
|
namespace N0 {
|
|
|
|
struct X0 {
|
|
|
|
int foo(int x) { return x; }
|
|
|
|
};
|
|
|
|
}
|
2009-11-08 09:45:36 +08:00
|
|
|
}
|
2009-11-08 19:36:54 +08:00
|
|
|
|
|
|
|
// PR5430
|
|
|
|
namespace pr5430 {
|
|
|
|
extern "C" void func(void);
|
|
|
|
}
|
|
|
|
using namespace pr5430;
|
|
|
|
extern "C" void pr5430::func(void) { }
|
2009-12-08 23:38:36 +08:00
|
|
|
|
2013-06-30 17:48:50 +08:00
|
|
|
// PR5405
|
2013-06-29 16:38:42 +08:00
|
|
|
int f2(char *)
|
2009-12-08 23:38:36 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2013-06-29 16:38:42 +08:00
|
|
|
int f2(int)
|
2009-12-08 23:38:36 +08:00
|
|
|
{
|
|
|
|
return f2((char *)0);
|
|
|
|
}
|
|
|
|
}
|
2010-07-31 00:47:02 +08:00
|
|
|
|
2013-06-30 17:48:50 +08:00
|
|
|
namespace PR5405 {
|
|
|
|
int f2b(char *) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
int f2b(int) {
|
|
|
|
return f2b((char *)0); // ok
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-31 00:47:02 +08:00
|
|
|
// PR6991
|
|
|
|
extern "C" typedef int (*PutcFunc_t)(int);
|
2010-08-12 15:09:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
// PR7859
|
|
|
|
extern "C" void pr7859_a(int) {} // expected-note {{previous definition}}
|
|
|
|
extern "C" void pr7859_a(int) {} // expected-error {{redefinition}}
|
|
|
|
|
|
|
|
extern "C" void pr7859_b() {} // expected-note {{previous definition}}
|
|
|
|
extern "C" void pr7859_b(int) {} // expected-error {{conflicting}}
|
|
|
|
|
|
|
|
extern "C" void pr7859_c(short) {} // expected-note {{previous definition}}
|
|
|
|
extern "C" void pr7859_c(int) {} // expected-error {{conflicting}}
|
2010-08-18 00:09:23 +08:00
|
|
|
|
|
|
|
// <rdar://problem/8318976>
|
|
|
|
extern "C" {
|
|
|
|
struct s0 {
|
|
|
|
private:
|
|
|
|
s0();
|
|
|
|
s0(const s0 &);
|
|
|
|
};
|
|
|
|
}
|
2010-08-24 22:14:45 +08:00
|
|
|
|
|
|
|
//PR7754
|
|
|
|
extern "C++" template <class T> int pr7754(T param);
|
|
|
|
|
|
|
|
namespace N {
|
|
|
|
int value;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C++" using N::value;
|
2010-10-15 09:21:46 +08:00
|
|
|
|
|
|
|
// PR7076
|
|
|
|
extern "C" const char *Version_string = "2.9";
|
2011-10-10 06:57:49 +08:00
|
|
|
|
2013-03-29 15:02:31 +08:00
|
|
|
extern "C" {
|
|
|
|
extern const char *Version_string2 = "2.9";
|
|
|
|
}
|
|
|
|
|
2011-10-10 06:57:49 +08:00
|
|
|
namespace PR9162 {
|
|
|
|
extern "C" {
|
|
|
|
typedef struct _ArtsSink ArtsSink;
|
|
|
|
struct _ArtsSink {
|
|
|
|
int sink;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
int arts_sink_get_type()
|
|
|
|
{
|
|
|
|
return sizeof(ArtsSink);
|
|
|
|
}
|
|
|
|
}
|
2013-05-06 02:24:05 +08:00
|
|
|
|
|
|
|
namespace pr14958 {
|
|
|
|
namespace js { extern int ObjectClass; }
|
|
|
|
extern "C" {
|
|
|
|
namespace js {}
|
|
|
|
}
|
|
|
|
int js::ObjectClass;
|
|
|
|
}
|
2013-05-29 08:56:45 +08:00
|
|
|
|
|
|
|
extern "C" void PR16167; // expected-error {{variable has incomplete type 'void'}}
|
2013-06-01 05:29:50 +08:00
|
|
|
extern void PR16167_0; // expected-error {{variable has incomplete type 'void'}}
|
2013-06-30 17:48:50 +08:00
|
|
|
|
|
|
|
// PR7927
|
|
|
|
enum T_7927 {
|
|
|
|
E_7927
|
|
|
|
};
|
|
|
|
|
|
|
|
extern "C" void f_pr7927(int);
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
extern "C" void f_pr7927(int);
|
|
|
|
|
|
|
|
void foo_pr7927() {
|
|
|
|
f_pr7927(E_7927);
|
|
|
|
f_pr7927(0);
|
|
|
|
::f_pr7927(E_7927);
|
|
|
|
::f_pr7927(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void bar_pr7927() {
|
|
|
|
f_pr7927(E_7927);
|
|
|
|
f_pr7927(0);
|
|
|
|
::f_pr7927(E_7927);
|
|
|
|
::f_pr7927(0);
|
|
|
|
}
|
2013-10-23 06:53:01 +08:00
|
|
|
|
|
|
|
namespace PR17337 {
|
|
|
|
extern "C++" {
|
|
|
|
class Foo;
|
|
|
|
extern "C" int bar3(Foo *y);
|
|
|
|
class Foo {
|
|
|
|
int x;
|
|
|
|
friend int bar3(Foo *y);
|
|
|
|
#ifdef W_RETAINED_LANGUAGE_LINKAGE
|
|
|
|
// expected-note@-5 {{previous declaration is here}}
|
|
|
|
// expected-warning@-3 {{retaining previous language linkage}}
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
extern "C" int bar3(Foo *y) {
|
|
|
|
return y->x;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|