14684ddb6SLionel Sambuc /*
24684ddb6SLionel Sambuc * Copyright 2010-2011 PathScale, Inc. All rights reserved.
34684ddb6SLionel Sambuc *
44684ddb6SLionel Sambuc * Redistribution and use in source and binary forms, with or without
54684ddb6SLionel Sambuc * modification, are permitted provided that the following conditions are met:
64684ddb6SLionel Sambuc *
74684ddb6SLionel Sambuc * 1. Redistributions of source code must retain the above copyright notice,
84684ddb6SLionel Sambuc * this list of conditions and the following disclaimer.
94684ddb6SLionel Sambuc *
104684ddb6SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright notice,
114684ddb6SLionel Sambuc * this list of conditions and the following disclaimer in the documentation
124684ddb6SLionel Sambuc * and/or other materials provided with the distribution.
134684ddb6SLionel Sambuc *
144684ddb6SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
154684ddb6SLionel Sambuc * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
164684ddb6SLionel Sambuc * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
174684ddb6SLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
184684ddb6SLionel Sambuc * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
194684ddb6SLionel Sambuc * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
204684ddb6SLionel Sambuc * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
214684ddb6SLionel Sambuc * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
224684ddb6SLionel Sambuc * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
234684ddb6SLionel Sambuc * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
244684ddb6SLionel Sambuc * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
254684ddb6SLionel Sambuc */
264684ddb6SLionel Sambuc
274684ddb6SLionel Sambuc /**
284684ddb6SLionel Sambuc * aux.cc - Compiler helper functions.
294684ddb6SLionel Sambuc *
304684ddb6SLionel Sambuc * The functions declared in this file are intended to be called only by code
314684ddb6SLionel Sambuc * that is automatically generated by C++ compilers for some common cases.
324684ddb6SLionel Sambuc */
334684ddb6SLionel Sambuc
344684ddb6SLionel Sambuc #include <stdlib.h>
354684ddb6SLionel Sambuc #include "stdexcept.h"
364684ddb6SLionel Sambuc
374684ddb6SLionel Sambuc /**
384684ddb6SLionel Sambuc * Called to generate a bad cast exception. This function is intended to allow
394684ddb6SLionel Sambuc * compilers to insert code generating this exception without needing to
404684ddb6SLionel Sambuc * duplicate the code for throwing the exception in every call site.
414684ddb6SLionel Sambuc */
__cxa_bad_cast()424684ddb6SLionel Sambuc extern "C" void __cxa_bad_cast()
434684ddb6SLionel Sambuc {
444684ddb6SLionel Sambuc throw std::bad_cast();
454684ddb6SLionel Sambuc }
464684ddb6SLionel Sambuc
474684ddb6SLionel Sambuc /**
484684ddb6SLionel Sambuc * Called to generate a bad typeid exception. This function is intended to
494684ddb6SLionel Sambuc * allow compilers to insert code generating this exception without needing to
504684ddb6SLionel Sambuc * duplicate the code for throwing the exception in every call site.
514684ddb6SLionel Sambuc */
__cxa_bad_typeid()524684ddb6SLionel Sambuc extern "C" void __cxa_bad_typeid()
534684ddb6SLionel Sambuc {
544684ddb6SLionel Sambuc throw std::bad_typeid();
554684ddb6SLionel Sambuc }
564684ddb6SLionel Sambuc
574684ddb6SLionel Sambuc /**
584684ddb6SLionel Sambuc * Compilers may (but are not required to) set any pure-virtual function's
594684ddb6SLionel Sambuc * vtable entry to this function. This makes debugging slightly easier, as
604684ddb6SLionel Sambuc * users can add a breakpoint on this function to tell if they've accidentally
614684ddb6SLionel Sambuc * called a pure-virtual function.
624684ddb6SLionel Sambuc */
__cxa_pure_virtual()634684ddb6SLionel Sambuc extern "C" void __cxa_pure_virtual()
644684ddb6SLionel Sambuc {
654684ddb6SLionel Sambuc abort();
664684ddb6SLionel Sambuc }
674684ddb6SLionel Sambuc
684684ddb6SLionel Sambuc /**
694684ddb6SLionel Sambuc * Compilers may (but are not required to) set any deleted-virtual function's
704684ddb6SLionel Sambuc * vtable entry to this function. This makes debugging slightly easier, as
714684ddb6SLionel Sambuc * users can add a breakpoint on this function to tell if they've accidentally
724684ddb6SLionel Sambuc * called a deleted-virtual function.
734684ddb6SLionel Sambuc */
__cxa_deleted_virtual()744684ddb6SLionel Sambuc extern "C" void __cxa_deleted_virtual()
754684ddb6SLionel Sambuc {
764684ddb6SLionel Sambuc abort();
774684ddb6SLionel Sambuc }
78*0a6a1f1dSLionel Sambuc
__cxa_throw_bad_array_new_length()79*0a6a1f1dSLionel Sambuc extern "C" void __cxa_throw_bad_array_new_length()
80*0a6a1f1dSLionel Sambuc {
81*0a6a1f1dSLionel Sambuc throw std::bad_array_new_length();
82*0a6a1f1dSLionel Sambuc }
83