Branch data Line data Source code
1 : : // rust-gcc.cc -- Rust frontend to gcc IR.
2 : : // Copyright (C) 2011-2024 Free Software Foundation, Inc.
3 : : // Contributed by Ian Lance Taylor, Google.
4 : : // forked from gccgo
5 : :
6 : : // This file is part of GCC.
7 : :
8 : : // GCC is free software; you can redistribute it and/or modify it under
9 : : // the terms of the GNU General Public License as published by the Free
10 : : // Software Foundation; either version 3, or (at your option) any later
11 : : // version.
12 : :
13 : : // GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 : : // WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 : : // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 : : // for more details.
17 : :
18 : : // You should have received a copy of the GNU General Public License
19 : : // along with GCC; see the file COPYING3. If not see
20 : : // <http://www.gnu.org/licenses/>.
21 : :
22 : : // This has to be included outside of extern "C", so we have to
23 : : // include it here before tree.h includes it later.
24 : :
25 : : #ifndef RUST_GCC
26 : : #define RUST_GCC
27 : :
28 : : #include "rust-location.h"
29 : :
30 : : // Bvariable is a bit more complicated, because of zero-sized types.
31 : : // The GNU linker does not permit dynamic variables with zero size.
32 : : // When we see such a variable, we generate a version of the type with
33 : : // non-zero size. However, when referring to the global variable, we
34 : : // want an expression of zero size; otherwise, if, say, the global
35 : : // variable is passed to a function, we will be passing a
36 : : // non-zero-sized value to a zero-sized value, which can lead to a
37 : : // miscompilation.
38 : :
39 : : class Bvariable
40 : : {
41 : : public:
42 : 31303 : Bvariable (tree t) : t_ (t), orig_type_ (NULL) {}
43 : :
44 : 38 : Bvariable (tree t, tree orig_type) : t_ (t), orig_type_ (orig_type) {}
45 : :
46 : : // Get the tree for use as an expression.
47 : : tree get_tree (location_t) const;
48 : :
49 : : // Get the actual decl;
50 : 15721 : tree get_decl () const { return this->t_; }
51 : :
52 : : // Create an error variable. This is used for cases which should
53 : : // not occur in a correct program, in order to keep the compilation
54 : : // going without crashing.
55 : : static Bvariable *error_variable ();
56 : :
57 : : private:
58 : : tree t_;
59 : : tree orig_type_;
60 : : };
61 : :
62 : : #endif // RUST_GCC
|