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