p3.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // A type-parameter defines its identifier to be a type-name (if
  3. // declared with class or typename) or template-name (if declared with
  4. // template) in the scope of the template declaration.
  5. template<typename T> struct X0 {
  6. T* value;
  7. };
  8. template<template<class T> class Y> struct X1 {
  9. Y<int> value;
  10. };
  11. // [Note: because of the name lookup rules, a template-parameter that
  12. // could be interpreted as either a non-type template-parameter or a
  13. // type-parameter (because its identifier is the name of an already
  14. // existing class) is taken as a type-parameter. For example,
  15. class T { /* ... */ }; // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
  16. int i;
  17. template<class T, T i> struct X2 {
  18. void f(T t)
  19. {
  20. T t1 = i; //template-parameters T and i
  21. ::T t2 = ::i; // global namespace members T and i \
  22. // expected-error{{no viable conversion}}
  23. }
  24. };
  25. namespace PR6831 {
  26. namespace NA { struct S; }
  27. namespace NB { struct S; }
  28. using namespace NA;
  29. using namespace NB;
  30. template <typename S> void foo();
  31. template <int S> void bar();
  32. template <template<typename> class S> void baz();
  33. }