goto_error_seq.cpp 600 B

123456789101112131415161718192021222324252627
  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/local_function.hpp>
  7. int error(int x, int y) {
  8. int BOOST_LOCAL_FUNCTION( (int z) ) {
  9. if(z <= 0) goto failure;
  10. else goto success;
  11. success:
  12. return 0;
  13. } BOOST_LOCAL_FUNCTION_NAME(validate)
  14. return validate(x + y);
  15. failure:
  16. return -1;
  17. }
  18. int main(void) {
  19. error(1, 2);
  20. return 0;
  21. }