head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC5:1.1.1.4
	netbsd-11-0-RC4:1.1.1.4
	netbsd-11-0-RC3:1.1.1.4
	netbsd-11-0-RC2:1.1.1.4
	netbsd-11-0-RC1:1.1.1.4
	perseant-exfatfs-base-20250801:1.1.1.4
	netbsd-11:1.1.1.4.0.10
	netbsd-11-base:1.1.1.4
	netbsd-10-1-RELEASE:1.1.1.4
	perseant-exfatfs-base-20240630:1.1.1.4
	perseant-exfatfs:1.1.1.4.0.8
	perseant-exfatfs-base:1.1.1.4
	netbsd-8-3-RELEASE:1.1.1.2
	netbsd-9-4-RELEASE:1.1.1.3
	netbsd-10-0-RELEASE:1.1.1.4
	netbsd-10-0-RC6:1.1.1.4
	netbsd-10-0-RC5:1.1.1.4
	netbsd-10-0-RC4:1.1.1.4
	netbsd-10-0-RC3:1.1.1.4
	netbsd-10-0-RC2:1.1.1.4
	netbsd-10-0-RC1:1.1.1.4
	netbsd-10:1.1.1.4.0.6
	netbsd-10-base:1.1.1.4
	netbsd-9-3-RELEASE:1.1.1.3
	cjep_sun2x:1.1.1.4.0.4
	cjep_sun2x-base:1.1.1.4
	cjep_staticlib_x-base1:1.1.1.4
	netbsd-9-2-RELEASE:1.1.1.3
	cjep_staticlib_x:1.1.1.4.0.2
	cjep_staticlib_x-base:1.1.1.4
	netbsd-9-1-RELEASE:1.1.1.3
	phil-wifi-20200421:1.1.1.4
	phil-wifi-20200411:1.1.1.4
	phil-wifi-20200406:1.1.1.4
	netbsd-8-2-RELEASE:1.1.1.2
	netbsd-9-0-RELEASE:1.1.1.3
	netbsd-9-0-RC2:1.1.1.3
	netbsd-9-0-RC1:1.1.1.3
	netbsd-9:1.1.1.3.0.2
	netbsd-9-base:1.1.1.3
	phil-wifi-20190609:1.1.1.3
	netbsd-8-1-RELEASE:1.1.1.2
	netbsd-8-1-RC1:1.1.1.2
	pgoyette-compat-merge-20190127:1.1.1.2.24.1
	pgoyette-compat-20190127:1.1.1.3
	pgoyette-compat-20190118:1.1.1.3
	pgoyette-compat-1226:1.1.1.3
	pgoyette-compat-1126:1.1.1.3
	pgoyette-compat-1020:1.1.1.3
	pgoyette-compat-0930:1.1.1.3
	pgoyette-compat-0906:1.1.1.3
	netbsd-7-2-RELEASE:1.1.1.2
	pgoyette-compat-0728:1.1.1.3
	clang-337282:1.1.1.3
	netbsd-8-0-RELEASE:1.1.1.2
	phil-wifi:1.1.1.2.0.26
	phil-wifi-base:1.1.1.2
	pgoyette-compat-0625:1.1.1.2
	netbsd-8-0-RC2:1.1.1.2
	pgoyette-compat-0521:1.1.1.2
	pgoyette-compat-0502:1.1.1.2
	pgoyette-compat-0422:1.1.1.2
	netbsd-8-0-RC1:1.1.1.2
	pgoyette-compat-0415:1.1.1.2
	pgoyette-compat-0407:1.1.1.2
	pgoyette-compat-0330:1.1.1.2
	pgoyette-compat-0322:1.1.1.2
	pgoyette-compat-0315:1.1.1.2
	netbsd-7-1-2-RELEASE:1.1.1.2
	pgoyette-compat:1.1.1.2.0.24
	pgoyette-compat-base:1.1.1.2
	netbsd-7-1-1-RELEASE:1.1.1.2
	clang-319952:1.1.1.2
	matt-nb8-mediatek:1.1.1.2.0.22
	matt-nb8-mediatek-base:1.1.1.2
	clang-309604:1.1.1.2
	perseant-stdc-iso10646:1.1.1.2.0.20
	perseant-stdc-iso10646-base:1.1.1.2
	netbsd-8:1.1.1.2.0.18
	netbsd-8-base:1.1.1.2
	prg-localcount2-base3:1.1.1.2
	prg-localcount2-base2:1.1.1.2
	prg-localcount2-base1:1.1.1.2
	prg-localcount2:1.1.1.2.0.16
	prg-localcount2-base:1.1.1.2
	pgoyette-localcount-20170426:1.1.1.2
	bouyer-socketcan-base1:1.1.1.2
	pgoyette-localcount-20170320:1.1.1.2
	netbsd-7-1:1.1.1.2.0.14
	netbsd-7-1-RELEASE:1.1.1.2
	netbsd-7-1-RC2:1.1.1.2
	clang-294123:1.1.1.2
	netbsd-7-nhusb-base-20170116:1.1.1.2
	bouyer-socketcan:1.1.1.2.0.12
	bouyer-socketcan-base:1.1.1.2
	clang-291444:1.1.1.2
	pgoyette-localcount-20170107:1.1.1.2
	netbsd-7-1-RC1:1.1.1.2
	pgoyette-localcount-20161104:1.1.1.2
	netbsd-7-0-2-RELEASE:1.1.1.2
	localcount-20160914:1.1.1.2
	netbsd-7-nhusb:1.1.1.2.0.10
	netbsd-7-nhusb-base:1.1.1.2
	clang-280599:1.1.1.2
	pgoyette-localcount-20160806:1.1.1.2
	pgoyette-localcount-20160726:1.1.1.2
	pgoyette-localcount:1.1.1.2.0.8
	pgoyette-localcount-base:1.1.1.2
	netbsd-7-0-1-RELEASE:1.1.1.2
	clang-261930:1.1.1.2
	netbsd-7-0:1.1.1.2.0.6
	netbsd-7-0-RELEASE:1.1.1.2
	netbsd-7-0-RC3:1.1.1.2
	netbsd-7-0-RC2:1.1.1.2
	netbsd-7-0-RC1:1.1.1.2
	clang-237755:1.1.1.2
	clang-232565:1.1.1.2
	clang-227398:1.1.1.2
	tls-maxphys-base:1.1.1.2
	tls-maxphys:1.1.1.2.0.4
	netbsd-7:1.1.1.2.0.2
	netbsd-7-base:1.1.1.2
	clang-215315:1.1.1.2
	clang-209886:1.1.1.2
	yamt-pagecache:1.1.1.1.0.4
	yamt-pagecache-base9:1.1.1.1
	tls-earlyentropy:1.1.1.1.0.2
	tls-earlyentropy-base:1.1.1.2
	riastradh-xf86-video-intel-2-7-1-pre-2-21-15:1.1.1.1
	riastradh-drm2-base3:1.1.1.1
	clang-202566:1.1.1.1
	clang-201163:1.1.1.1
	clang-199312:1.1.1.1
	clang-198450:1.1.1.1
	clang-196603:1.1.1.1
	clang-195771:1.1.1.1
	LLVM:1.1.1;
locks; strict;
comment	@// @;


1.1
date	2013.11.28.14.14.56;	author joerg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	ow8OybrawrB1f3fx;

1.1.1.1
date	2013.11.28.14.14.56;	author joerg;	state Exp;
branches
	1.1.1.1.2.1
	1.1.1.1.4.1;
next	1.1.1.2;
commitid	ow8OybrawrB1f3fx;

1.1.1.2
date	2014.05.30.18.14.49;	author joerg;	state Exp;
branches
	1.1.1.2.4.1
	1.1.1.2.24.1
	1.1.1.2.26.1;
next	1.1.1.3;
commitid	8q0kdlBlCn09GACx;

1.1.1.3
date	2018.07.17.18.31.33;	author joerg;	state Exp;
branches;
next	1.1.1.4;
commitid	wDzL46ALjrCZgwKA;

1.1.1.4
date	2019.11.13.22.22.55;	author joerg;	state dead;
branches;
next	;
commitid	QD8YATxuNG34YJKB;

1.1.1.1.2.1
date	2014.08.10.07.08.23;	author tls;	state Exp;
branches;
next	;
commitid	t01A1TLTYxkpGMLx;

1.1.1.1.4.1
date	2013.11.28.14.14.56;	author yamt;	state dead;
branches;
next	1.1.1.1.4.2;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.1.4.2
date	2014.05.22.16.19.40;	author yamt;	state Exp;
branches;
next	;
commitid	WSrDtL5nYAUyiyBx;

1.1.1.2.4.1
date	2014.05.30.18.14.49;	author tls;	state dead;
branches;
next	1.1.1.2.4.2;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.2.4.2
date	2014.08.19.23.49.18;	author tls;	state Exp;
branches;
next	;
commitid	jTnpym9Qu0o4R1Nx;

1.1.1.2.24.1
date	2018.07.28.04.34.12;	author pgoyette;	state Exp;
branches;
next	;
commitid	1UP1xAIUxv1ZgRLA;

1.1.1.2.26.1
date	2019.06.10.21.46.35;	author christos;	state Exp;
branches;
next	1.1.1.2.26.2;
commitid	jtc8rnCzWiEEHGqB;

1.1.1.2.26.2
date	2020.04.13.07.50.22;	author martin;	state dead;
branches;
next	;
commitid	X01YhRUPVUDaec4C;


desc
@@


1.1
log
@Initial revision
@
text
@// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -Wno-local-type-template-args %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -Wno-local-type-template-args -fmodules %s

namespace test1 {
  int x; // expected-note {{previous definition is here}}
  static int y;
  void f() {} // expected-note {{previous definition is here}}

  extern "C" {
    extern int x; // expected-error {{declaration of 'x' has a different language linkage}}
    extern int y; // OK, has internal linkage, so no language linkage.
    void f(); // expected-error {{declaration of 'f' has a different language linkage}}
  }
}

// This is OK. Both test2_f don't have language linkage since they have
// internal linkage.
extern "C" {
  static void test2_f() {
  }
  static void test2_f(int x) {
  }
}

namespace test3 {
  extern "C" {
    namespace {
      extern int x2;
      void f2();
    }
  }
  namespace {
    int x2;
    void f2() {}
  }
}

namespace test4 {
  void dummy() {
    void Bar();
    class A {
      friend void Bar();
    };
  }
}

namespace test5 {
  static void g();
  void f()
  {
    void g();
  }
}

// pr14898
namespace test6 {
  template <class _Rp>
  class __attribute__ ((__visibility__("default"))) shared_future;
  template <class _Rp>
  class future {
    template <class> friend class shared_future;
    shared_future<_Rp> share();
  };
  template <class _Rp> future<_Rp>
  get_future();
  template <class _Rp>
  struct shared_future<_Rp&> {
    shared_future(future<_Rp&>&& __f);
  };
  void f() {
    typedef int T;
    get_future<int>();
    typedef int& U;
    shared_future<int&> f1 = get_future<int&>();
  }
}

// This is OK. The variables have internal linkage and therefore no language
// linkage.
extern "C" {
  static int test7_x;
}
extern "C++" {
  extern int test7_x;
}
extern "C++" {
  static int test7_y;
}
extern "C" {
  extern int test7_y;
}
extern "C" { typedef int test7_F(); static test7_F test7_f; }
extern "C++" { extern test7_F test7_f; }

// FIXME: This should be invalid. The function has no language linkage, but
// the function type has, so this is redeclaring the function with a different
// type.
extern "C++" {
  static void test8_f();
}
extern "C" {
  extern void test8_f();
}
extern "C" {
  static void test8_g();
}
extern "C++" {
  extern void test8_g();
}

extern "C" {
  void __attribute__((overloadable)) test9_f(int c); // expected-note {{previous declaration is here}}
}
extern "C++" {
  void __attribute__((overloadable)) test9_f(int c); // expected-error {{declaration of 'test9_f' has a different language linkage}}
}

extern "C" {
  void __attribute__((overloadable)) test10_f(int);
  void __attribute__((overloadable)) test10_f(double);
}

extern "C" {
  void test11_f() {
    void  __attribute__((overloadable)) test11_g(int);
    void  __attribute__((overloadable)) test11_g(double);
  }
}

namespace test12 {
  const int n = 0;
  extern const int n;
  void f() {
    extern const int n;
  }
}

namespace test13 {
  static void a(void);
  extern void a();
  static void a(void) {}
}

namespace test14 {
  namespace {
    void a(void); // expected-note {{previous declaration is here}}
    static void a(void) {} // expected-error {{static declaration of 'a' follows non-static declaration}}
  }
}

namespace test15 {
  const int a = 5; // expected-note {{previous definition is here}}
  static const int a; // expected-error {{redefinition of 'a'}}
}

namespace test16 {
  extern "C" {
    class Foo {
      int x;
      friend int bar(Foo *y);
    };
    int bar(Foo *y) {
      return y->x;
    }
  }
}

namespace test17 {
  namespace {
    struct I {
    };
  }
  template <typename T1, typename T2> void foo() {}
  template <typename T, T x> void bar() {} // expected-note {{candidate function}}
  inline void *g() {
    struct L {
    };
    // foo<L, I>'s linkage should be the merge of UniqueExternalLinkage (or
    // InternalLinkage in c++11) and VisibleNoLinkage. The correct answer is
    // NoLinkage in both cases. This means that using foo<L, I> as a template
    // argument should fail.
    return reinterpret_cast<void*>(bar<typeof(foo<L, I>), foo<L, I> >); // expected-error {{reinterpret_cast cannot resolve overloaded function 'bar' to type 'void *}}
  }
  void h() {
    g();
  }
}

namespace test18 {
  template <typename T> struct foo {
    template <T *P> static void f() {}
    static void *g() { return (void *)f<&x>; }
    static T x;
  };
  template <typename T> T foo<T>::x;
  inline void *f() {
    struct S {
    };
    return foo<S>::g();
  }
  void *h() { return f(); }
}

extern "C" void pr16247_foo(int);
static void pr16247_foo(double);
void pr16247_foo(int) {}
void pr16247_foo(double) {}

namespace PR16247 {
  extern "C" void pr16247_bar(int);
  static void pr16247_bar(double);
  void pr16247_bar(int) {}
  void pr16247_bar(double) {}
}
@


1.1.1.1
log
@Import Clang 3.4rc1 r195771.
@
text
@@


1.1.1.1.2.1
log
@Rebase.
@
text
@a215 4
namespace PR18964 {
  unsigned &*foo; //expected-error{{'foo' declared as a pointer to a reference of type}}
  extern struct {} *foo; // don't assert
}
@


1.1.1.2
log
@Import Clang 3.5svn r209886.
@
text
@a215 4
namespace PR18964 {
  unsigned &*foo; //expected-error{{'foo' declared as a pointer to a reference of type}}
  extern struct {} *foo; // don't assert
}
@


1.1.1.2.26.1
log
@Sync with HEAD
@
text
@a145 1
  // Anonymous namespace implies internal linkage, so 'static' has no effect.
d147 2
a148 2
    void a(void);
    static void a(void) {}
a219 31

namespace typedef_name_for_linkage {
  template<typename T> struct Use {};

  struct A { A(); A(const A&); ~A(); };

  typedef struct {
    A a;
  } B;

  struct C {
    typedef struct {
      A a;
    } D;
  };

  typedef struct {
    void f() { static int n; struct Inner {};}
  } E;

  // FIXME: Ideally this would be accepted in all modes. In C++98, we trigger a
  // linkage calculation to drive the "internal linkage type as template
  // argument" warning.
  typedef struct {
    void f() { struct Inner {}; Use<Inner> ui; }
  } F;
#if __cplusplus < 201103L
  // expected-error@@-2 {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}}
  // expected-note@@-5 {{use a tag name here}}
#endif
}
@


1.1.1.2.26.2
log
@Mostly merge changes from HEAD upto 20200411
@
text
@@


1.1.1.2.24.1
log
@Sync with HEAD
@
text
@a145 1
  // Anonymous namespace implies internal linkage, so 'static' has no effect.
d147 2
a148 2
    void a(void);
    static void a(void) {}
a219 31

namespace typedef_name_for_linkage {
  template<typename T> struct Use {};

  struct A { A(); A(const A&); ~A(); };

  typedef struct {
    A a;
  } B;

  struct C {
    typedef struct {
      A a;
    } D;
  };

  typedef struct {
    void f() { static int n; struct Inner {};}
  } E;

  // FIXME: Ideally this would be accepted in all modes. In C++98, we trigger a
  // linkage calculation to drive the "internal linkage type as template
  // argument" warning.
  typedef struct {
    void f() { struct Inner {}; Use<Inner> ui; }
  } F;
#if __cplusplus < 201103L
  // expected-error@@-2 {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}}
  // expected-note@@-5 {{use a tag name here}}
#endif
}
@


1.1.1.3
log
@Import clang r337282 from trunk
@
text
@a145 1
  // Anonymous namespace implies internal linkage, so 'static' has no effect.
d147 2
a148 2
    void a(void);
    static void a(void) {}
a219 31

namespace typedef_name_for_linkage {
  template<typename T> struct Use {};

  struct A { A(); A(const A&); ~A(); };

  typedef struct {
    A a;
  } B;

  struct C {
    typedef struct {
      A a;
    } D;
  };

  typedef struct {
    void f() { static int n; struct Inner {};}
  } E;

  // FIXME: Ideally this would be accepted in all modes. In C++98, we trigger a
  // linkage calculation to drive the "internal linkage type as template
  // argument" warning.
  typedef struct {
    void f() { struct Inner {}; Use<Inner> ui; }
  } F;
#if __cplusplus < 201103L
  // expected-error@@-2 {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}}
  // expected-note@@-5 {{use a tag name here}}
#endif
}
@


1.1.1.4
log
@Mark old LLVM instance as dead.
@
text
@@


1.1.1.2.4.1
log
@file linkage2.cpp was added on branch tls-maxphys on 2014-08-19 23:49:18 +0000
@
text
@d1 219
@


1.1.1.2.4.2
log
@Rebase to HEAD as of a few days ago.
@
text
@a0 219
// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -Wno-local-type-template-args %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -Wno-local-type-template-args -fmodules %s

namespace test1 {
  int x; // expected-note {{previous definition is here}}
  static int y;
  void f() {} // expected-note {{previous definition is here}}

  extern "C" {
    extern int x; // expected-error {{declaration of 'x' has a different language linkage}}
    extern int y; // OK, has internal linkage, so no language linkage.
    void f(); // expected-error {{declaration of 'f' has a different language linkage}}
  }
}

// This is OK. Both test2_f don't have language linkage since they have
// internal linkage.
extern "C" {
  static void test2_f() {
  }
  static void test2_f(int x) {
  }
}

namespace test3 {
  extern "C" {
    namespace {
      extern int x2;
      void f2();
    }
  }
  namespace {
    int x2;
    void f2() {}
  }
}

namespace test4 {
  void dummy() {
    void Bar();
    class A {
      friend void Bar();
    };
  }
}

namespace test5 {
  static void g();
  void f()
  {
    void g();
  }
}

// pr14898
namespace test6 {
  template <class _Rp>
  class __attribute__ ((__visibility__("default"))) shared_future;
  template <class _Rp>
  class future {
    template <class> friend class shared_future;
    shared_future<_Rp> share();
  };
  template <class _Rp> future<_Rp>
  get_future();
  template <class _Rp>
  struct shared_future<_Rp&> {
    shared_future(future<_Rp&>&& __f);
  };
  void f() {
    typedef int T;
    get_future<int>();
    typedef int& U;
    shared_future<int&> f1 = get_future<int&>();
  }
}

// This is OK. The variables have internal linkage and therefore no language
// linkage.
extern "C" {
  static int test7_x;
}
extern "C++" {
  extern int test7_x;
}
extern "C++" {
  static int test7_y;
}
extern "C" {
  extern int test7_y;
}
extern "C" { typedef int test7_F(); static test7_F test7_f; }
extern "C++" { extern test7_F test7_f; }

// FIXME: This should be invalid. The function has no language linkage, but
// the function type has, so this is redeclaring the function with a different
// type.
extern "C++" {
  static void test8_f();
}
extern "C" {
  extern void test8_f();
}
extern "C" {
  static void test8_g();
}
extern "C++" {
  extern void test8_g();
}

extern "C" {
  void __attribute__((overloadable)) test9_f(int c); // expected-note {{previous declaration is here}}
}
extern "C++" {
  void __attribute__((overloadable)) test9_f(int c); // expected-error {{declaration of 'test9_f' has a different language linkage}}
}

extern "C" {
  void __attribute__((overloadable)) test10_f(int);
  void __attribute__((overloadable)) test10_f(double);
}

extern "C" {
  void test11_f() {
    void  __attribute__((overloadable)) test11_g(int);
    void  __attribute__((overloadable)) test11_g(double);
  }
}

namespace test12 {
  const int n = 0;
  extern const int n;
  void f() {
    extern const int n;
  }
}

namespace test13 {
  static void a(void);
  extern void a();
  static void a(void) {}
}

namespace test14 {
  namespace {
    void a(void); // expected-note {{previous declaration is here}}
    static void a(void) {} // expected-error {{static declaration of 'a' follows non-static declaration}}
  }
}

namespace test15 {
  const int a = 5; // expected-note {{previous definition is here}}
  static const int a; // expected-error {{redefinition of 'a'}}
}

namespace test16 {
  extern "C" {
    class Foo {
      int x;
      friend int bar(Foo *y);
    };
    int bar(Foo *y) {
      return y->x;
    }
  }
}

namespace test17 {
  namespace {
    struct I {
    };
  }
  template <typename T1, typename T2> void foo() {}
  template <typename T, T x> void bar() {} // expected-note {{candidate function}}
  inline void *g() {
    struct L {
    };
    // foo<L, I>'s linkage should be the merge of UniqueExternalLinkage (or
    // InternalLinkage in c++11) and VisibleNoLinkage. The correct answer is
    // NoLinkage in both cases. This means that using foo<L, I> as a template
    // argument should fail.
    return reinterpret_cast<void*>(bar<typeof(foo<L, I>), foo<L, I> >); // expected-error {{reinterpret_cast cannot resolve overloaded function 'bar' to type 'void *}}
  }
  void h() {
    g();
  }
}

namespace test18 {
  template <typename T> struct foo {
    template <T *P> static void f() {}
    static void *g() { return (void *)f<&x>; }
    static T x;
  };
  template <typename T> T foo<T>::x;
  inline void *f() {
    struct S {
    };
    return foo<S>::g();
  }
  void *h() { return f(); }
}

extern "C" void pr16247_foo(int);
static void pr16247_foo(double);
void pr16247_foo(int) {}
void pr16247_foo(double) {}

namespace PR16247 {
  extern "C" void pr16247_bar(int);
  static void pr16247_bar(double);
  void pr16247_bar(int) {}
  void pr16247_bar(double) {}
}
namespace PR18964 {
  unsigned &*foo; //expected-error{{'foo' declared as a pointer to a reference of type}}
  extern struct {} *foo; // don't assert
}
@


1.1.1.1.4.1
log
@file linkage2.cpp was added on branch yamt-pagecache on 2014-05-22 16:19:40 +0000
@
text
@d1 215
@


1.1.1.1.4.2
log
@sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")
@
text
@a0 215
// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -Wno-local-type-template-args %s
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions -Wno-local-type-template-args -fmodules %s

namespace test1 {
  int x; // expected-note {{previous definition is here}}
  static int y;
  void f() {} // expected-note {{previous definition is here}}

  extern "C" {
    extern int x; // expected-error {{declaration of 'x' has a different language linkage}}
    extern int y; // OK, has internal linkage, so no language linkage.
    void f(); // expected-error {{declaration of 'f' has a different language linkage}}
  }
}

// This is OK. Both test2_f don't have language linkage since they have
// internal linkage.
extern "C" {
  static void test2_f() {
  }
  static void test2_f(int x) {
  }
}

namespace test3 {
  extern "C" {
    namespace {
      extern int x2;
      void f2();
    }
  }
  namespace {
    int x2;
    void f2() {}
  }
}

namespace test4 {
  void dummy() {
    void Bar();
    class A {
      friend void Bar();
    };
  }
}

namespace test5 {
  static void g();
  void f()
  {
    void g();
  }
}

// pr14898
namespace test6 {
  template <class _Rp>
  class __attribute__ ((__visibility__("default"))) shared_future;
  template <class _Rp>
  class future {
    template <class> friend class shared_future;
    shared_future<_Rp> share();
  };
  template <class _Rp> future<_Rp>
  get_future();
  template <class _Rp>
  struct shared_future<_Rp&> {
    shared_future(future<_Rp&>&& __f);
  };
  void f() {
    typedef int T;
    get_future<int>();
    typedef int& U;
    shared_future<int&> f1 = get_future<int&>();
  }
}

// This is OK. The variables have internal linkage and therefore no language
// linkage.
extern "C" {
  static int test7_x;
}
extern "C++" {
  extern int test7_x;
}
extern "C++" {
  static int test7_y;
}
extern "C" {
  extern int test7_y;
}
extern "C" { typedef int test7_F(); static test7_F test7_f; }
extern "C++" { extern test7_F test7_f; }

// FIXME: This should be invalid. The function has no language linkage, but
// the function type has, so this is redeclaring the function with a different
// type.
extern "C++" {
  static void test8_f();
}
extern "C" {
  extern void test8_f();
}
extern "C" {
  static void test8_g();
}
extern "C++" {
  extern void test8_g();
}

extern "C" {
  void __attribute__((overloadable)) test9_f(int c); // expected-note {{previous declaration is here}}
}
extern "C++" {
  void __attribute__((overloadable)) test9_f(int c); // expected-error {{declaration of 'test9_f' has a different language linkage}}
}

extern "C" {
  void __attribute__((overloadable)) test10_f(int);
  void __attribute__((overloadable)) test10_f(double);
}

extern "C" {
  void test11_f() {
    void  __attribute__((overloadable)) test11_g(int);
    void  __attribute__((overloadable)) test11_g(double);
  }
}

namespace test12 {
  const int n = 0;
  extern const int n;
  void f() {
    extern const int n;
  }
}

namespace test13 {
  static void a(void);
  extern void a();
  static void a(void) {}
}

namespace test14 {
  namespace {
    void a(void); // expected-note {{previous declaration is here}}
    static void a(void) {} // expected-error {{static declaration of 'a' follows non-static declaration}}
  }
}

namespace test15 {
  const int a = 5; // expected-note {{previous definition is here}}
  static const int a; // expected-error {{redefinition of 'a'}}
}

namespace test16 {
  extern "C" {
    class Foo {
      int x;
      friend int bar(Foo *y);
    };
    int bar(Foo *y) {
      return y->x;
    }
  }
}

namespace test17 {
  namespace {
    struct I {
    };
  }
  template <typename T1, typename T2> void foo() {}
  template <typename T, T x> void bar() {} // expected-note {{candidate function}}
  inline void *g() {
    struct L {
    };
    // foo<L, I>'s linkage should be the merge of UniqueExternalLinkage (or
    // InternalLinkage in c++11) and VisibleNoLinkage. The correct answer is
    // NoLinkage in both cases. This means that using foo<L, I> as a template
    // argument should fail.
    return reinterpret_cast<void*>(bar<typeof(foo<L, I>), foo<L, I> >); // expected-error {{reinterpret_cast cannot resolve overloaded function 'bar' to type 'void *}}
  }
  void h() {
    g();
  }
}

namespace test18 {
  template <typename T> struct foo {
    template <T *P> static void f() {}
    static void *g() { return (void *)f<&x>; }
    static T x;
  };
  template <typename T> T foo<T>::x;
  inline void *f() {
    struct S {
    };
    return foo<S>::g();
  }
  void *h() { return f(); }
}

extern "C" void pr16247_foo(int);
static void pr16247_foo(double);
void pr16247_foo(int) {}
void pr16247_foo(double) {}

namespace PR16247 {
  extern "C" void pr16247_bar(int);
  static void pr16247_bar(double);
  void pr16247_bar(int) {}
  void pr16247_bar(double) {}
}
@


