brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · a4492ba Raw
58 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s4 5class C {6  friend class D;7};8 9class A {10public:11  void f();12};13 14friend int x; // expected-error {{'friend' used outside of class}}15 16friend class D {}; // expected-error {{'friend' used outside of class}}17 18union U {19  int u1;20};21 22class B {23  // 'A' here should refer to the declaration above.  24  friend class A;25 26  friend C;27#if __cplusplus <= 199711L28  // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'class' to befriend 'C'}}29#endif30 31  friend U;32#if __cplusplus <= 199711L33  // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'union' to befriend 'U'}}34#endif35 36  friend int;37#if __cplusplus <= 199711L38  // expected-warning@-2 {{non-class friend type 'int' is a C++11 extension}}39#endif40 41  friend void myfunc();42 43  void f(A *a) { a->f(); }44};45 46inline void bar() {} // expected-note {{previous definition is here}}47class E {48  friend void bar() {} // expected-error {{redefinition of 'bar'}}49};50 51 52 53 54template <typename t1, typename t2> class some_template;55friend   // expected-error {{'friend' used outside of class}}56some_template<foo, bar>&  // expected-error {{use of undeclared identifier 'foo'}}57  ;  // expected-error {{expected unqualified-id}}58