103 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3namespace test0 {4 template <class T> class A {5 class Member {};6 };7 8 class B {9 template <class T> friend class A<T>::Member; // expected-warning {{not supported}}10 int n;11 };12 13 A<int> a;14 B b;15}16 17namespace test1 {18 template <class T> struct A;19 20 class C {21 static void foo();22 template <class T> friend void A<T>::f(); // expected-warning {{not supported}}23 };24 25 template <class T> struct A {26 void f() { C::foo(); }27 };28 29 template <class T> struct A<T*> {30 void f() { C::foo(); }31 };32 33 template <> struct A<char> {34 void f() { C::foo(); }35 };36}37 38// FIXME: these should fail!39namespace test2 {40 template <class T> struct A;41 42 class C {43 static void foo();44 template <class T> friend void A<T>::g(); // expected-warning {{not supported}}45 };46 47 template <class T> struct A {48 void f() { C::foo(); }49 };50 51 template <class T> struct A<T*> {52 void f() { C::foo(); }53 };54 55 template <> struct A<char> {56 void f() { C::foo(); }57 };58}59 60namespace test3 {61 template <class T> struct A {62 struct Inner {63 static int foo();64 };65 };66 67 template <class U> class C {68 int i;69 template <class T> friend struct A<T>::Inner; // expected-warning {{not supported}}70 };71 72 template <class T> int A<T>::Inner::foo() {73 C<int> c;74 c.i = 0;75 return 0;76 }77 78 int test = A<int>::Inner::foo();79}80 81namespace test4 {82 template <class T> struct X {83 template <class U> void operator+=(U);84 85 template <class V>86 template <class U>87 friend void X<V>::operator+=(U); // expected-warning {{not supported}}88 };89 90 void test() { 91 X<int>() += 1.0;92 }93}94 95namespace test5 {96 template<template <class> class T> struct A {97 template<template <class> class U> friend void A<U>::foo(); // expected-warning {{not supported}}98 };99 100 template <class> struct B {};101 template class A<B>;102}103