linkage2.cpp revision 013539cddae154cd1782984a7dc3bb471cac397e
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2 3namespace test1 { 4 int x; // expected-note {{previous definition is here}} 5 static int y; // expected-note {{previous definition is here}} 6 void f() {} // expected-note {{previous definition is here}} 7 8 extern "C" { 9 extern int x; // expected-error {{declaration of 'x' has a different language linkage}} 10 extern int y; // expected-error {{declaration of 'y' has a different language linkage}} 11 void f(); // expected-error {{declaration of 'f' has a different language linkage}} 12 } 13} 14 15extern "C" { 16 static void test2_f() { // expected-note {{previous definition is here}} 17 } 18 static void test2_f(int x) { // expected-error {{conflicting types for 'test2_f'}} 19 } 20} 21 22namespace test3 { 23 extern "C" { 24 namespace { 25 extern int x2; 26 void f2(); 27 } 28 } 29 namespace { 30 int x2; 31 void f2() {} 32 } 33} 34 35namespace test4 { 36 void dummy() { 37 void Bar(); 38 class A { 39 friend void Bar(); 40 }; 41 } 42} 43 44namespace test5 { 45 static void g(); 46 void f() 47 { 48 void g(); 49 } 50} 51 52// pr14898 53namespace test6 { 54 template <class _Rp> 55 class __attribute__ ((__visibility__("default"))) shared_future; 56 template <class _Rp> 57 class future { 58 template <class> friend class shared_future; 59 shared_future<_Rp> share(); 60 }; 61 template <class _Rp> future<_Rp> 62 get_future(); 63 template <class _Rp> 64 struct shared_future<_Rp&> { 65 shared_future(future<_Rp&>&& __f); // expected-warning {{rvalue references are a C++11 extension}} 66 }; 67 void f() { 68 typedef int T; 69 get_future<int>(); 70 typedef int& U; 71 shared_future<int&> f1 = get_future<int&>(); 72 } 73} 74