1*0a6a1f1dSLionel Sambuc // RUN: rm -rf %t
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=1
3*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -x c++ -I%S/Inputs/merge-using-decls -verify %s -DORDER=2
4*0a6a1f1dSLionel Sambuc
5*0a6a1f1dSLionel Sambuc #if ORDER == 1
6*0a6a1f1dSLionel Sambuc #include "a.h"
7*0a6a1f1dSLionel Sambuc #include "b.h"
8*0a6a1f1dSLionel Sambuc #else
9*0a6a1f1dSLionel Sambuc #include "b.h"
10*0a6a1f1dSLionel Sambuc #include "a.h"
11*0a6a1f1dSLionel Sambuc #endif
12*0a6a1f1dSLionel Sambuc
13*0a6a1f1dSLionel Sambuc struct Y {
14*0a6a1f1dSLionel Sambuc int value; // expected-note 0-1{{target of using}}
15*0a6a1f1dSLionel Sambuc typedef int type; // expected-note 0-1{{target of using}}
16*0a6a1f1dSLionel Sambuc };
17*0a6a1f1dSLionel Sambuc
Use()18*0a6a1f1dSLionel Sambuc template<typename T> int Use() {
19*0a6a1f1dSLionel Sambuc int k = T().v + T().value; // expected-note 0-2{{instantiation of}}
20*0a6a1f1dSLionel Sambuc typedef typename T::type I;
21*0a6a1f1dSLionel Sambuc typedef typename T::t I;
22*0a6a1f1dSLionel Sambuc typedef int I;
23*0a6a1f1dSLionel Sambuc return k;
24*0a6a1f1dSLionel Sambuc }
25*0a6a1f1dSLionel Sambuc
UseAll()26*0a6a1f1dSLionel Sambuc template<typename T> int UseAll() {
27*0a6a1f1dSLionel Sambuc return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
28*0a6a1f1dSLionel Sambuc }
29*0a6a1f1dSLionel Sambuc
30*0a6a1f1dSLionel Sambuc template int UseAll<YA>();
31*0a6a1f1dSLionel Sambuc template int UseAll<YB>();
32*0a6a1f1dSLionel Sambuc template int UseAll<Y>();
33*0a6a1f1dSLionel Sambuc
34*0a6a1f1dSLionel Sambuc #if ORDER == 1
35*0a6a1f1dSLionel Sambuc // Here, we're instantiating the definition from 'A' and merging the definition
36*0a6a1f1dSLionel Sambuc // from 'B' into it.
37*0a6a1f1dSLionel Sambuc
38*0a6a1f1dSLionel Sambuc // expected-error@b.h:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
39*0a6a1f1dSLionel Sambuc // expected-error@b.h:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
40*0a6a1f1dSLionel Sambuc
41*0a6a1f1dSLionel Sambuc // expected-error@b.h:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
42*0a6a1f1dSLionel Sambuc // expected-error@b.h:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
43*0a6a1f1dSLionel Sambuc // expected-error@b.h:* {{'F::value' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
44*0a6a1f1dSLionel Sambuc // expected-error@b.h:* {{'F::v' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
45*0a6a1f1dSLionel Sambuc
46*0a6a1f1dSLionel Sambuc // expected-note@a.h:* +{{does not match}}
47*0a6a1f1dSLionel Sambuc #else
48*0a6a1f1dSLionel Sambuc // Here, we're instantiating the definition from 'B' and merging the definition
49*0a6a1f1dSLionel Sambuc // from 'A' into it.
50*0a6a1f1dSLionel Sambuc
51*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'D::type' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
52*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'D::value' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
53*0a6a1f1dSLionel Sambuc // expected-error@b.h:* 2{{'typename' keyword used on a non-type}}
54*0a6a1f1dSLionel Sambuc // expected-error@b.h:* 2{{dependent using declaration resolved to type without 'typename'}}
55*0a6a1f1dSLionel Sambuc
56*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
57*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
58*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
59*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
60*0a6a1f1dSLionel Sambuc // expected-note@b.h:* 2{{definition has no member}}
61*0a6a1f1dSLionel Sambuc
62*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
63*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
64*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'F::value' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
65*0a6a1f1dSLionel Sambuc // expected-error@a.h:* {{'F::v' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
66*0a6a1f1dSLionel Sambuc
67*0a6a1f1dSLionel Sambuc // expected-note@b.h:* +{{does not match}}
68*0a6a1f1dSLionel Sambuc // expected-note@b.h:* +{{target of using}}
69*0a6a1f1dSLionel Sambuc #endif
70