instantiate-scope.cpp 852 B

123456789101112131415161718192021222324252627282930
  1. // RUN: %clang_cc1 -std=c++11 -verify %s
  2. template<typename ...T> struct X {
  3. void f(int);
  4. void f(...);
  5. static int n;
  6. };
  7. template<typename T, typename U> using A = T;
  8. // These definitions are OK, X<A<T, decltype(...)>...> is equivalent to X<T...>
  9. // so this defines the member of the primary template.
  10. template<typename ...T>
  11. void X<A<T, decltype(f(T()))>...>::f(int) {} // expected-error {{undeclared}}
  12. template<typename ...T>
  13. int X<A<T, decltype(f(T()))>...>::n = 0; // expected-error {{undeclared}}
  14. struct Y {}; void f(Y);
  15. void g() {
  16. // OK, substitution succeeds.
  17. X<Y>().f(0);
  18. X<Y>::n = 1;
  19. // Error, substitution fails; this should not be treated as a SFINAE-able
  20. // condition, so we don't select X<void>::f(...).
  21. X<void>().f(0); // expected-note {{instantiation of}}
  22. X<void>::n = 1; // expected-note {{instantiation of}}
  23. }