cxx-chain-function-template.cpp 472 B

1234567891011121314151617181920212223242526272829303132
  1. // RUN: %clang_cc1 -chain-include %s -chain-include %s -fsyntax-only %s
  2. // Just don't crash.
  3. #if !defined(RUN1)
  4. #define RUN1
  5. struct CXXRecordDecl { CXXRecordDecl(int); };
  6. template <typename T, typename U>
  7. T cast(U u) {
  8. return reinterpret_cast<T&>(u);
  9. }
  10. void test1() {
  11. cast<float>(1);
  12. }
  13. #elif !defined(RUN2)
  14. #define RUN2
  15. template <typename T>
  16. void test2(T) {
  17. cast<CXXRecordDecl>(1.0f);
  18. }
  19. #else
  20. void test3() {
  21. cast<CXXRecordDecl>(1.0f);
  22. test2(1);
  23. }
  24. #endif