cxx_exprs.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Test this without pch.
  2. // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -include %S/cxx_exprs.h -std=c++11 -fsyntax-only -verify %s -ast-dump
  3. // Test with pch. Use '-ast-dump' to force deserialization of function bodies.
  4. // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -x c++-header -std=c++11 -emit-pch -o %t %S/cxx_exprs.h
  5. // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-dump
  6. // expected-no-diagnostics
  7. int integer;
  8. double floating;
  9. char character;
  10. bool boolean;
  11. // CXXStaticCastExpr
  12. static_cast_result void_ptr = &integer;
  13. // CXXDynamicCastExpr
  14. Derived *d;
  15. dynamic_cast_result derived_ptr = d;
  16. // CXXReinterpretCastExpr
  17. reinterpret_cast_result void_ptr2 = &integer;
  18. // CXXConstCastExpr
  19. const_cast_result char_ptr = &character;
  20. // CXXFunctionalCastExpr
  21. functional_cast_result *double_ptr = &floating;
  22. // CXXBoolLiteralExpr
  23. bool_literal_result *bool_ptr = &boolean;
  24. static_assert(true_value, "true_value is true");
  25. static_assert(!false_value, "false_value is false");
  26. // CXXNullPtrLiteralExpr
  27. cxx_null_ptr_result null_ptr = nullptr;
  28. // CXXTypeidExpr
  29. typeid_result1 typeid_1 = 0;
  30. typeid_result2 typeid_2 = 0;
  31. // CharacterLiteral variants
  32. static_assert(char_value == 97, "char_value is correct");
  33. static_assert(wchar_t_value == 305, "wchar_t_value is correct");
  34. static_assert(char16_t_value == 231, "char16_t_value is correct");
  35. static_assert(char32_t_value == 8706, "char32_t_value is correct");