goto.cpp 751 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (C) 2009-2012 Lorenzo Caminiti
  2. // Distributed under the Boost Software License, Version 1.0
  3. // (see accompanying file LICENSE_1_0.txt or a copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Home at http://www.boost.org/libs/local_function
  6. #include <boost/config.hpp>
  7. #ifdef BOOST_NO_CXX11_VARIADIC_MACROS
  8. # error "variadic macros required"
  9. #else
  10. #include <boost/local_function.hpp>
  11. //[goto
  12. int error(int x, int y) {
  13. int BOOST_LOCAL_FUNCTION(int z) {
  14. if(z > 0) goto success; // OK: Can jump within local function.
  15. return -1;
  16. success:
  17. return 0;
  18. } BOOST_LOCAL_FUNCTION_NAME(validate)
  19. return validate(x + y);
  20. }
  21. //]
  22. int main(void) {
  23. error(1, 2);
  24. return 0;
  25. }
  26. #endif // VARIADIC_MACROS