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

source code of boost/libs/local_function/test/goto_error.cpp