merge-using-decls.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. #if ORDER == 1
  5. #include "a.h"
  6. #include "b.h"
  7. #else
  8. #include "b.h"
  9. #include "a.h"
  10. #endif
  11. struct Y {
  12. int value; // expected-note 0-1{{target of using}}
  13. typedef int type; // expected-note 0-1{{target of using}}
  14. };
  15. template<typename T> int Use() {
  16. int k = T().v + T().value; // expected-note 0-2{{instantiation of}}
  17. typedef typename T::type I;
  18. typedef typename T::t I;
  19. typedef int I;
  20. return k;
  21. }
  22. template<typename T> int UseAll() {
  23. return Use<C<T> >() + Use<D<T> >() + Use<E<T> >() + Use<F<T> >(); // expected-note 0-2{{instantiation of}}
  24. }
  25. template int UseAll<YA>();
  26. template int UseAll<YB>();
  27. template int UseAll<Y>();
  28. #if ORDER == 1
  29. // Here, we're instantiating the definition from 'A' and merging the definition
  30. // from 'B' into it.
  31. // expected-error@b.h:* {{'E::value' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
  32. // expected-error@b.h:* {{'E::v' from module 'B' is not present in definition of 'E<T>' in module 'A'}}
  33. // expected-error@b.h:* {{'F::type' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
  34. // expected-error@b.h:* {{'F::t' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
  35. // expected-error@b.h:* {{'F::value' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
  36. // expected-error@b.h:* {{'F::v' from module 'B' is not present in definition of 'F<T>' in module 'A'}}
  37. // expected-note@a.h:* +{{does not match}}
  38. #else
  39. // Here, we're instantiating the definition from 'B' and merging the definition
  40. // from 'A' into it.
  41. // expected-error@a.h:* {{'D::type' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
  42. // expected-error@a.h:* {{'D::value' from module 'A' is not present in definition of 'D<T>' in module 'B'}}
  43. // expected-error@b.h:* 2{{'typename' keyword used on a non-type}}
  44. // expected-error@b.h:* 2{{dependent using declaration resolved to type without 'typename'}}
  45. // expected-error@a.h:* {{'E::type' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
  46. // expected-error@a.h:* {{'E::t' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
  47. // expected-error@a.h:* {{'E::value' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
  48. // expected-error@a.h:* {{'E::v' from module 'A' is not present in definition of 'E<T>' in module 'B'}}
  49. // expected-note@b.h:* 2{{definition has no member}}
  50. // expected-error@a.h:* {{'F::type' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
  51. // expected-error@a.h:* {{'F::t' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
  52. // expected-error@a.h:* {{'F::value' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
  53. // expected-error@a.h:* {{'F::v' from module 'A' is not present in definition of 'F<T>' in module 'B'}}
  54. // expected-note@b.h:* +{{does not match}}
  55. // expected-note@b.h:* +{{target of using}}
  56. #endif