1 // RUN: rm -rf %t
2 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=1
3 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++98 %s -DORDER=1
4 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++11 %s -DORDER=1
5 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2
6 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++98 %s -DORDER=2
7 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify -std=c++11 %s -DORDER=2
8 
9 #if ORDER == 1
10 #include "a.h"
11 #include "b.h"
12 #else
13 #include "b.h"
14 #include "a.h"
15 #endif
16 
17 struct Y {
18   int value; // expected-note 0-1{{target of using}}
19   typedef int type; // expected-note 0-1{{target of using}}
20 };
21 
22 template<typename T> int Use() {
23   int k = T().v + T().value; // expected-note 0-2{{instantiation of}}
24   typedef typename T::type I;
25   typedef typename T::t I;
26   typedef int I;
27   return k;
28 }
29 
30 template<typename T> int UseAll() {
31 #if __cplusplus <= 199711L // C++11 does not allow access declarations
32   return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
33 #else
34   return Use<C<T> >() + Use<D<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
35 #endif
36 }
37 
38 template int UseAll<YA>();
39 template int UseAll<YB>();
40 template int UseAll<Y>();
41 
42 // Which of these two sets of diagnostics is chosen is not important. It's OK
43 // if this varies with ORDER, but it must be consistent across runs.
44 #if ORDER == 1
45 // Here, we're instantiating the definition from 'A' and merging the definition
46 // from 'B' into it.
47 
48 #if __cplusplus <= 199711L // C++11 does not allow access declarations
49 // [email protected]:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
50 // [email protected]:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
51 #endif
52 
53 // [email protected]:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
54 // [email protected]:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
55 // [email protected]:* {{'F::value' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
56 // [email protected]:* {{'F::v' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
57 
58 // [email protected]:* +{{does not match}}
59 #else
60 // Here, we're instantiating the definition from 'B' and merging the definition
61 // from 'A' into it.
62 
63 // [email protected]:* {{'D::type' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
64 // [email protected]:* {{'D::value' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
65 // [email protected]:* 2{{'typename' keyword used on a non-type}}
66 // [email protected]:* 2{{dependent using declaration resolved to type without 'typename'}}
67 
68 #if __cplusplus <= 199711L // C++11 does not allow access declarations
69 // [email protected]:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
70 // [email protected]:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
71 // [email protected]:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
72 // [email protected]:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
73 // [email protected]:* 2{{definition has no member}}
74 #endif
75 
76 
77 // [email protected]:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
78 // [email protected]:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
79 // [email protected]:* {{'F::value' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
80 // [email protected]:* {{'F::v' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
81 
82 // [email protected]:* +{{does not match}}
83 // [email protected]:* +{{target of using}}
84 #endif
85