compiler: don't insert write barriers if we've seen errors
[official-gcc.git] / libobjc / nil_method.c
blob178c695883f69368d88432259e99dfa5cd38897d
1 /* GNU Objective C Runtime nil receiver function
2 Copyright (C) 1993-2018 Free Software Foundation, Inc.
3 Contributed by Kresten Krab Thorup
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation; either version 3, or (at your option) any later version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 details.
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
26 /* This is the nil method, the function that is called when the receiver
27 of a method is nil */
29 #include "objc-private/common.h"
30 #include "objc/objc.h"
32 /* When the receiver of a method invocation is nil, the runtime
33 returns nil_method() as the method implementation. This function
34 will be casted to whatever function was supposed to be executed to
35 execute that method (that function will take an id, followed by a
36 SEL, followed by who knows what arguments, depends on the method),
37 and executed.
39 For this reason, nil_method() should be a function which can be
40 called in place of any function taking an 'id' argument followed by
41 a 'SEL' argument, followed by zero, or one, or any number of
42 arguments (both a fixed number, or a variable number !).
44 There is no "proper" implementation of such a nil_method function
45 in C, however in all existing implementations it does not matter
46 when extra arguments are present, so we can simply create a function
47 taking a receiver and a selector, and all other arguments will be
48 ignored. :-)
52 nil_method (id receiver, SEL op __attribute__ ((__unused__)))
54 return receiver;