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