1 /* d-lang.cc -- Language-dependent hooks for D.
2 Copyright (C) 2006-2020 Free Software Foundation, Inc.
4 GCC is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3, or (at your option)
9 GCC is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with GCC; see the file COPYING3. If not see
16 <http://www.gnu.org/licenses/>. */
20 #include "coretypes.h"
22 #include "dmd/aggregate.h"
24 #include "dmd/declaration.h"
26 #include "dmd/errors.h"
27 #include "dmd/expression.h"
28 #include "dmd/hdrgen.h"
29 #include "dmd/identifier.h"
31 #include "dmd/mangle.h"
33 #include "dmd/module.h"
34 #include "dmd/mtype.h"
35 #include "dmd/target.h"
40 #include "diagnostic.h"
41 #include "fold-const.h"
43 #include "langhooks.h"
44 #include "langhooks-def.h"
46 #include "stringpool.h"
47 #include "stor-layout.h"
50 #include "print-tree.h"
51 #include "gimple-expr.h"
59 /* Array of D frontend type/decl nodes. */
60 tree d_global_trees
[DTI_MAX
];
62 /* True if compilation is currently inside the D frontend semantic passes. */
63 bool doing_semantic_analysis_p
= false;
65 /* Options handled by the compiler that are separate from the frontend. */
68 const char *fonly
; /* -fonly=<arg> */
69 const char *multilib
; /* -imultilib <dir> */
70 const char *prefix
; /* -iprefix <dir> */
73 bool deps_skip_system
; /* -MM */
74 const char *deps_filename
; /* -M[M]D */
75 const char *deps_filename_user
; /* -MF <arg> */
76 OutBuffer
*deps_target
; /* -M[QT] <arg> */
77 bool deps_phony
; /* -MP */
79 bool stdinc
; /* -nostdinc */
83 /* List of modules being compiled. */
84 static Modules builtin_modules
;
86 /* Module where `C main' is defined, compiled in if needed. */
87 static Module
*entrypoint_module
= NULL
;
88 static Module
*entrypoint_root_module
= NULL
;
90 /* The current and global binding level in effect. */
91 struct binding_level
*current_binding_level
;
92 struct binding_level
*global_binding_level
;
94 /* The context to be used for global declarations. */
95 static GTY(()) tree global_context
;
97 /* Array of all global declarations to pass back to the middle-end. */
98 static GTY(()) vec
<tree
, va_gc
> *global_declarations
;
100 /* Support for GCC-style command-line make dependency generation.
101 Adds TARGET to the make dependencies target buffer.
102 QUOTED is true if the string should be quoted. */
105 deps_add_target (const char *target
, bool quoted
)
107 if (!d_option
.deps_target
)
108 d_option
.deps_target
= new OutBuffer ();
110 d_option
.deps_target
->writeByte (' ');
112 d_option
.deps_target
->reserve (strlen (target
));
116 d_option
.deps_target
->writestring (target
);
120 /* Quote characters in target which are significant to Make. */
121 for (const char *p
= target
; *p
!= '\0'; p
++)
127 for (const char *q
= p
- 1; target
<= q
&& *q
== '\\'; q
--)
128 d_option
.deps_target
->writeByte ('\\');
129 d_option
.deps_target
->writeByte ('\\');
133 d_option
.deps_target
->writeByte ('$');
137 d_option
.deps_target
->writeByte ('\\');
144 d_option
.deps_target
->writeByte (*p
);
148 /* Write out all dependencies of a given MODULE to the specified BUFFER.
149 COLMAX is the number of columns to word-wrap at (0 means don't wrap). */
152 deps_write (Module
*module
, OutBuffer
*buffer
, unsigned colmax
= 72)
154 hash_set
<const char *> seen_modules
;
155 vec
<const char *> dependencies
= vNULL
;
158 modlist
.push (module
);
160 vec
<const char *> phonylist
= vNULL
;
163 /* Write out make target module name. */
164 if (d_option
.deps_target
)
166 buffer
->writestring (d_option
.deps_target
->extractString ());
167 column
= d_option
.deps_target
->offset
;
171 buffer
->writestring (module
->objfile
->name
->str
);
172 column
= buffer
->offset
;
175 buffer
->writestring (":");
178 /* Search all modules for file dependencies. */
179 while (modlist
.length
> 0)
181 Module
*depmod
= modlist
.pop ();
183 const char *modstr
= depmod
->srcfile
->name
->str
;
185 /* Skip modules that have already been looked at. */
186 if (seen_modules
.add (modstr
))
189 dependencies
.safe_push (modstr
);
191 /* Add to list of phony targets if is not being compile. */
192 if (d_option
.deps_phony
&& !depmod
->isRoot ())
193 phonylist
.safe_push (modstr
);
195 /* Add imported files to dependency list. */
196 for (size_t i
= 0; i
< depmod
->contentImportedFiles
.length
; i
++)
198 const char *impstr
= depmod
->contentImportedFiles
[i
];
199 dependencies
.safe_push (impstr
);
200 phonylist
.safe_push (impstr
);
203 /* Search all imports of the module. */
204 for (size_t i
= 0; i
< depmod
->aimports
.length
; i
++)
206 Module
*m
= depmod
->aimports
[i
];
208 /* Ignore compiler-generated modules. */
209 if ((m
->ident
== Identifier::idPool ("__entrypoint")
210 || m
->ident
== Identifier::idPool ("__main"))
211 && m
->parent
== NULL
)
214 /* Don't search system installed modules, this includes
215 object, core.*, std.*, and gcc.* packages. */
216 if (d_option
.deps_skip_system
)
218 if (m
->ident
== Identifier::idPool ("object")
219 && m
->parent
== NULL
)
222 if (m
->md
&& m
->md
->packages
)
224 Identifier
*package
= (*m
->md
->packages
)[0];
226 if (package
== Identifier::idPool ("core")
227 || package
== Identifier::idPool ("std")
228 || package
== Identifier::idPool ("gcc"))
237 /* Write out all make dependencies. */
238 for (size_t i
= 0; i
< dependencies
.length (); i
++)
240 const char *str
= dependencies
[i
];
241 unsigned size
= strlen (str
);
244 if (colmax
&& column
> colmax
)
246 buffer
->writestring (" \\\n ");
251 buffer
->writestring (" ");
255 buffer
->writestring (str
);
260 /* Write out all phony targets. */
261 for (size_t i
= 0; i
< phonylist
.length (); i
++)
264 buffer
->writestring (phonylist
[i
]);
265 buffer
->writestring (":\n");
269 /* Implements the lang_hooks.init_options routine for language D.
270 This initializes the global state for the D frontend before calling
271 the option handlers. */
274 d_init_options (unsigned int, cl_decoded_option
*decoded_options
)
276 /* Set default values. */
279 global
.vendor
= lang_hooks
.name
;
280 global
.params
.argv0
= xstrdup (decoded_options
[0].arg
);
281 global
.params
.link
= true;
282 global
.params
.useAssert
= true;
283 global
.params
.useInvariants
= true;
284 global
.params
.useIn
= true;
285 global
.params
.useOut
= true;
286 global
.params
.useArrayBounds
= BOUNDSCHECKdefault
;
287 global
.params
.useSwitchError
= true;
288 global
.params
.useModuleInfo
= true;
289 global
.params
.useTypeInfo
= true;
290 global
.params
.useExceptions
= true;
291 global
.params
.useInline
= false;
292 global
.params
.obj
= true;
293 global
.params
.hdrStripPlainFunctions
= true;
294 global
.params
.betterC
= false;
295 global
.params
.allInst
= false;
297 /* Default extern(C++) mangling to C++14. */
298 global
.params
.cplusplus
= CppStdRevisionCpp14
;
300 global
.params
.linkswitches
= new Strings ();
301 global
.params
.libfiles
= new Strings ();
302 global
.params
.objfiles
= new Strings ();
303 global
.params
.ddocfiles
= new Strings ();
305 /* Warnings and deprecations are disabled by default. */
306 global
.params
.useDeprecated
= DIAGNOSTICoff
;
307 global
.params
.warnings
= DIAGNOSTICoff
;
309 global
.params
.imppath
= new Strings ();
310 global
.params
.fileImppath
= new Strings ();
311 global
.params
.modFileAliasStrings
= new Strings ();
313 /* Extra GDC-specific options. */
314 d_option
.fonly
= NULL
;
315 d_option
.multilib
= NULL
;
316 d_option
.prefix
= NULL
;
317 d_option
.deps
= false;
318 d_option
.deps_skip_system
= false;
319 d_option
.deps_filename
= NULL
;
320 d_option
.deps_filename_user
= NULL
;
321 d_option
.deps_target
= NULL
;
322 d_option
.deps_phony
= false;
323 d_option
.stdinc
= true;
326 /* Implements the lang_hooks.init_options_struct routine for language D.
327 Initializes the options structure OPTS. */
330 d_init_options_struct (gcc_options
*opts
)
333 opts
->x_flag_exceptions
= 1;
335 /* Avoid range issues for complex multiply and divide. */
336 opts
->x_flag_complex_method
= 2;
338 /* Unlike C, there is no global 'errno' variable. */
339 opts
->x_flag_errno_math
= 0;
340 opts
->frontend_set_flag_errno_math
= true;
342 /* Keep in sync with existing -fbounds-check flag. */
343 opts
->x_flag_bounds_check
= global
.params
.useArrayBounds
;
345 /* D says that signed overflow is precisely defined. */
346 opts
->x_flag_wrapv
= 1;
349 /* Implements the lang_hooks.lang_mask routine for language D.
350 Returns language mask for option parsing. */
353 d_option_lang_mask (void)
358 /* Implements the lang_hooks.init routine for language D. */
366 Expression::_init ();
370 global_binding_level
= ggc_cleared_alloc
<binding_level
> ();
371 current_binding_level
= global_binding_level
;
373 /* This allows the code in d-builtins.cc to not have to worry about
374 converting (C signed char *) to (D char *) for string arguments of
375 built-in functions. The parameter (signed_char = false) specifies
376 whether char is signed. */
377 build_common_tree_nodes (false);
382 using_eh_for_cleanups ();
384 if (!supports_one_only ())
387 /* This is the C main, not the D main. */
388 main_identifier_node
= get_identifier ("main");
393 /* Insert all library-configured identifiers and import paths. */
394 add_import_paths (d_option
.prefix
, d_option
.multilib
, d_option
.stdinc
);
399 /* Implements the lang_hooks.init_ts routine for language D. */
404 MARK_TS_TYPED (FLOAT_MOD_EXPR
);
405 MARK_TS_TYPED (UNSIGNED_RSHIFT_EXPR
);
408 /* Implements the lang_hooks.handle_option routine for language D.
409 Handles D specific options. Return false if we didn't do anything. */
412 d_handle_option (size_t scode
, const char *arg
, HOST_WIDE_INT value
,
413 int kind ATTRIBUTE_UNUSED
,
414 location_t loc ATTRIBUTE_UNUSED
,
415 const cl_option_handlers
*handlers ATTRIBUTE_UNUSED
)
417 opt_code code
= (opt_code
) scode
;
422 case OPT_fall_instantiations
:
423 global
.params
.allInst
= value
;
427 global
.params
.useAssert
= value
;
430 case OPT_fbounds_check
:
431 global
.params
.useArrayBounds
= value
432 ? BOUNDSCHECKon
: BOUNDSCHECKoff
;
435 case OPT_fbounds_check_
:
436 global
.params
.useArrayBounds
= (value
== 2) ? BOUNDSCHECKon
437 : (value
== 1) ? BOUNDSCHECKsafeonly
: BOUNDSCHECKoff
;
441 global
.params
.debuglevel
= value
? 1 : 0;
445 if (ISDIGIT (arg
[0]))
447 int level
= integral_argument (arg
);
450 DebugCondition::setGlobalLevel (level
);
455 if (Identifier::isValidIdentifier (CONST_CAST (char *, arg
)))
457 DebugCondition::addGlobalIdent (arg
);
461 error ("bad argument for %<-fdebug%>: %qs", arg
);
465 global
.params
.doDocComments
= value
;
469 global
.params
.doDocComments
= true;
470 global
.params
.docdir
= arg
;
474 global
.params
.doDocComments
= true;
475 global
.params
.docname
= arg
;
479 global
.params
.ddocfiles
->push (arg
);
483 global
.params
.betterC
= !value
;
486 case OPT_fdump_d_original
:
487 global
.params
.vcg_ast
= value
;
490 case OPT_fexceptions
:
491 global
.params
.useExceptions
= value
;
494 case OPT_fignore_unknown_pragmas
:
495 global
.params
.ignoreUnsupportedPragmas
= value
;
498 case OPT_finvariants
:
499 global
.params
.useInvariants
= value
;
503 global
.params
.addMain
= value
;
506 case OPT_fmodule_file_
:
507 global
.params
.modFileAliasStrings
->push (arg
);
508 if (!strchr (arg
, '='))
509 error ("bad argument for %<-fmodule-file%>: %qs", arg
);
512 case OPT_fmoduleinfo
:
513 global
.params
.useModuleInfo
= value
;
517 d_option
.fonly
= arg
;
520 case OPT_fpostconditions
:
521 global
.params
.useOut
= value
;
524 case OPT_fpreconditions
:
525 global
.params
.useIn
= value
;
529 global
.params
.release
= value
;
533 global
.params
.useTypeInfo
= value
;
536 case OPT_fswitch_errors
:
537 global
.params
.useSwitchError
= value
;
540 case OPT_ftransition_all
:
541 global
.params
.vtls
= value
;
542 global
.params
.vfield
= value
;
543 global
.params
.vcomplex
= value
;
546 case OPT_ftransition_checkimports
:
547 global
.params
.check10378
= value
;
550 case OPT_ftransition_complex
:
551 global
.params
.vcomplex
= value
;
554 case OPT_ftransition_dip1000
:
555 global
.params
.vsafe
= value
;
556 global
.params
.useDIP25
= value
;
559 case OPT_ftransition_dip25
:
560 global
.params
.useDIP25
= value
;
563 case OPT_ftransition_field
:
564 global
.params
.vfield
= value
;
567 case OPT_ftransition_import
:
568 global
.params
.bug10378
= value
;
571 case OPT_ftransition_nogc
:
572 global
.params
.vgc
= value
;
575 case OPT_ftransition_tls
:
576 global
.params
.vtls
= value
;
580 global
.params
.useUnitTests
= value
;
584 if (ISDIGIT (arg
[0]))
586 int level
= integral_argument (arg
);
589 VersionCondition::setGlobalLevel (level
);
594 if (Identifier::isValidIdentifier (CONST_CAST (char *, arg
)))
596 VersionCondition::addGlobalIdent (arg
);
600 error ("bad argument for %<-fversion%>: %qs", arg
);
604 global
.params
.doHdrGeneration
= true;
608 global
.params
.doHdrGeneration
= true;
609 global
.params
.hdrdir
= arg
;
613 global
.params
.doHdrGeneration
= true;
614 global
.params
.hdrname
= arg
;
618 d_option
.multilib
= arg
;
622 d_option
.prefix
= arg
;
626 global
.params
.imppath
->push (arg
);
630 global
.params
.fileImppath
->push (arg
);
634 d_option
.deps_skip_system
= true;
638 d_option
.deps
= true;
642 d_option
.deps_skip_system
= true;
646 d_option
.deps
= true;
647 d_option
.deps_filename
= arg
;
651 /* If specified multiple times, last one wins. */
652 d_option
.deps_filename_user
= arg
;
656 d_option
.deps_phony
= true;
660 deps_add_target (arg
, true);
664 deps_add_target (arg
, false);
668 d_option
.stdinc
= false;
672 global
.params
.verbose
= value
;
677 global
.params
.warnings
= DIAGNOSTICinform
;
680 case OPT_Wdeprecated
:
681 global
.params
.useDeprecated
= value
? DIAGNOSTICinform
: DIAGNOSTICoff
;
686 global
.params
.warnings
= DIAGNOSTICerror
;
689 case OPT_Wspeculative
:
691 global
.params
.showGaggedErrors
= 1;
695 global
.params
.jsonfilename
= arg
;
699 global
.params
.doJsonGeneration
= true;
706 D_handle_option_auto (&global_options
, &global_options_set
,
708 d_option_lang_mask (), kind
,
709 loc
, handlers
, global_dc
);
714 /* Implements the lang_hooks.post_options routine for language D.
715 Deal with any options that imply the turning on/off of features.
716 FN is the main input filename passed on the command line. */
719 d_post_options (const char ** fn
)
721 /* Verify the input file name. */
722 const char *filename
= *fn
;
723 if (!filename
|| strcmp (filename
, "-") == 0)
726 /* The front end considers the first input file to be the main one. */
729 /* Release mode doesn't turn off bounds checking for safe functions. */
730 if (global
.params
.useArrayBounds
== BOUNDSCHECKdefault
)
732 global
.params
.useArrayBounds
= global
.params
.release
733 ? BOUNDSCHECKsafeonly
: BOUNDSCHECKon
;
734 flag_bounds_check
= !global
.params
.release
;
737 if (global
.params
.release
)
739 if (!global_options_set
.x_flag_invariants
)
740 global
.params
.useInvariants
= false;
742 if (!global_options_set
.x_flag_preconditions
)
743 global
.params
.useIn
= false;
745 if (!global_options_set
.x_flag_postconditions
)
746 global
.params
.useOut
= false;
748 if (!global_options_set
.x_flag_assert
)
749 global
.params
.useAssert
= false;
751 if (!global_options_set
.x_flag_switch_errors
)
752 global
.params
.useSwitchError
= false;
755 if (global
.params
.betterC
)
757 if (!global_options_set
.x_flag_moduleinfo
)
758 global
.params
.useModuleInfo
= false;
760 if (!global_options_set
.x_flag_rtti
)
761 global
.params
.useTypeInfo
= false;
763 if (!global_options_set
.x_flag_exceptions
)
764 global
.params
.useExceptions
= false;
766 global
.params
.checkAction
= CHECKACTION_halt
;
769 /* Turn off partitioning unless it was explicitly requested, as it doesn't
770 work with D exception chaining, where EH handler uses LSDA to determine
771 whether two thrown exception are in the same context. */
772 if (!global_options_set
.x_flag_reorder_blocks_and_partition
)
773 global_options
.x_flag_reorder_blocks_and_partition
= 0;
775 /* Error about use of deprecated features. */
776 if (global
.params
.useDeprecated
== DIAGNOSTICinform
777 && global
.params
.warnings
== DIAGNOSTICerror
)
778 global
.params
.useDeprecated
= DIAGNOSTICerror
;
780 /* Make -fmax-errors visible to frontend's diagnostic machinery. */
781 if (global_options_set
.x_flag_max_errors
)
782 global
.errorLimit
= flag_max_errors
;
784 if (flag_excess_precision
== EXCESS_PRECISION_DEFAULT
)
785 flag_excess_precision
= EXCESS_PRECISION_STANDARD
;
787 if (global
.params
.useUnitTests
)
788 global
.params
.useAssert
= true;
790 global
.params
.symdebug
= write_symbols
!= NO_DEBUG
;
791 global
.params
.useInline
= flag_inline_functions
;
792 global
.params
.showColumns
= flag_show_column
;
794 if (global
.params
.useInline
)
795 global
.params
.hdrStripPlainFunctions
= false;
797 global
.params
.obj
= !flag_syntax_only
;
799 /* Has no effect yet. */
800 global
.params
.pic
= flag_pic
!= 0;
802 if (warn_return_type
== -1)
803 warn_return_type
= 0;
808 /* Return TRUE if an operand OP of a given TYPE being copied has no data.
809 The middle-end does a similar check with zero sized types. */
812 empty_modify_p (tree type
, tree op
)
814 tree_code code
= TREE_CODE (op
);
818 return empty_modify_p (type
, TREE_OPERAND (op
, 1));
821 /* Non-empty construcors are valid. */
822 if (CONSTRUCTOR_NELTS (op
) != 0 || TREE_CLOBBER_P (op
))
827 /* Leave nrvo alone because it isn't a copy. */
828 if (CALL_EXPR_RETURN_SLOT_OPT (op
))
833 /* If the operand doesn't have a simple form. */
834 if (!is_gimple_lvalue (op
) && !INDIRECT_REF_P (op
))
839 return empty_aggregate_p (type
);
842 /* Implements the lang_hooks.gimplify_expr routine for language D.
843 Do gimplification of D specific expression trees in EXPR_P. */
846 d_gimplify_expr (tree
*expr_p
, gimple_seq
*pre_p
,
847 gimple_seq
*post_p ATTRIBUTE_UNUSED
)
849 tree_code code
= TREE_CODE (*expr_p
);
850 enum gimplify_status ret
= GS_UNHANDLED
;
858 op0
= TREE_OPERAND (*expr_p
, 0);
859 op1
= TREE_OPERAND (*expr_p
, 1);
861 if (!error_operand_p (op0
) && !error_operand_p (op1
)
862 && (AGGREGATE_TYPE_P (TREE_TYPE (op0
))
863 || AGGREGATE_TYPE_P (TREE_TYPE (op1
)))
864 && !useless_type_conversion_p (TREE_TYPE (op1
), TREE_TYPE (op0
)))
866 /* If the back end isn't clever enough to know that the lhs and rhs
867 types are the same, add an explicit conversion. */
868 TREE_OPERAND (*expr_p
, 1) = build1 (VIEW_CONVERT_EXPR
,
869 TREE_TYPE (op0
), op1
);
872 else if (empty_modify_p (TREE_TYPE (op0
), op1
))
874 /* Remove any copies of empty aggregates. */
875 gimplify_expr (&TREE_OPERAND (*expr_p
, 0), pre_p
, post_p
,
876 is_gimple_lvalue
, fb_lvalue
);
878 if (TREE_SIDE_EFFECTS (op1
))
879 gimplify_and_add (op1
, pre_p
);
881 *expr_p
= TREE_OPERAND (*expr_p
, 0);
887 op0
= TREE_OPERAND (*expr_p
, 0);
888 /* Constructors are not lvalues, so make them one. */
889 if (TREE_CODE (op0
) == CONSTRUCTOR
)
891 TREE_OPERAND (*expr_p
, 0) = force_target_expr (op0
);
897 if (CALL_EXPR_ARGS_ORDERED (*expr_p
))
899 /* Strictly evaluate all arguments from left to right. */
900 int nargs
= call_expr_nargs (*expr_p
);
901 location_t loc
= EXPR_LOC_OR_LOC (*expr_p
, input_location
);
903 /* No need to enforce evaluation order if only one argument. */
907 /* Or if all arguments are already free of side-effects. */
908 bool has_side_effects
= false;
909 for (int i
= 0; i
< nargs
; i
++)
911 if (TREE_SIDE_EFFECTS (CALL_EXPR_ARG (*expr_p
, i
)))
913 has_side_effects
= true;
918 if (!has_side_effects
)
921 /* Leave the last argument for gimplify_call_expr. */
922 for (int i
= 0; i
< nargs
- 1; i
++)
924 tree new_arg
= CALL_EXPR_ARG (*expr_p
, i
);
926 /* If argument has a side-effect, gimplify_arg will handle it. */
927 if (gimplify_arg (&new_arg
, pre_p
, loc
) == GS_ERROR
)
930 /* Even if an argument itself doesn't have any side-effects, it
931 might be altered by another argument in the list. */
932 if (new_arg
== CALL_EXPR_ARG (*expr_p
, i
)
933 && !really_constant_p (new_arg
))
934 new_arg
= get_formal_tmp_var (new_arg
, pre_p
);
936 CALL_EXPR_ARG (*expr_p
, i
) = new_arg
;
944 case UNSIGNED_RSHIFT_EXPR
:
945 /* Convert op0 to an unsigned type. */
946 op0
= TREE_OPERAND (*expr_p
, 0);
947 op1
= TREE_OPERAND (*expr_p
, 1);
949 type
= d_unsigned_type (TREE_TYPE (op0
));
951 *expr_p
= convert (TREE_TYPE (*expr_p
),
952 build2 (RSHIFT_EXPR
, type
, convert (type
, op0
), op1
));
966 /* Add the module M to the list of modules that may declare GCC builtins.
967 These are scanned after first semantic and before codegen passes.
968 See d_maybe_set_builtin() for the implementation. */
971 d_add_builtin_module (Module
*m
)
973 builtin_modules
.push (m
);
976 /* Record the entrypoint module ENTRY which will be compiled in the current
977 compilation. ROOT is the module scope where this was requested from. */
980 d_add_entrypoint_module (Module
*entry
, Module
*root
)
982 /* We are emitting this straight to object file. */
983 entrypoint_module
= entry
;
984 entrypoint_root_module
= root
;
987 /* Implements the lang_hooks.parse_file routine for language D. */
992 if (global
.params
.verbose
)
994 message ("binary %s", global
.params
.argv0
);
995 message ("version %s", global
.version
);
997 if (global
.params
.versionids
)
1000 buf
.writestring ("predefs ");
1001 for (size_t i
= 0; i
< global
.params
.versionids
->length
; i
++)
1003 const char *s
= (*global
.params
.versionids
)[i
];
1004 buf
.writestring (" ");
1005 buf
.writestring (s
);
1008 message ("%.*s", (int) buf
.offset
, (char *) buf
.data
);
1012 /* Start the main input file, if the debug writer wants it. */
1013 if (debug_hooks
->start_end_main_source_file
)
1014 debug_hooks
->start_source_file (0, main_input_filename
);
1016 /* Create Module's for all sources we will load. */
1018 modules
.reserve (num_in_fnames
);
1020 /* In this mode, the first file name is supposed to be a duplicate
1021 of one of the input files. */
1022 if (d_option
.fonly
&& strcmp (d_option
.fonly
, main_input_filename
) != 0)
1023 error ("%<-fonly=%> argument is different from first input file name");
1025 for (size_t i
= 0; i
< num_in_fnames
; i
++)
1027 if (strcmp (in_fnames
[i
], "-") == 0)
1029 /* Handling stdin, generate a unique name for the module. */
1031 gcc_obstack_init (&buffer
);
1034 Module
*m
= Module::create (in_fnames
[i
],
1035 Identifier::generateId ("__stdin"),
1036 global
.params
.doDocComments
,
1037 global
.params
.doHdrGeneration
);
1040 /* Load the entire contents of stdin into memory. */
1041 while ((c
= getc (stdin
)) != EOF
)
1042 obstack_1grow (&buffer
, c
);
1044 if (!obstack_object_size (&buffer
))
1045 obstack_1grow (&buffer
, '\0');
1047 /* Overwrite the source file for the module, the one created by
1048 Module::create would have a forced a `.d' suffix. */
1049 m
->srcfile
= File::create ("<stdin>");
1050 m
->srcfile
->len
= obstack_object_size (&buffer
);
1051 m
->srcfile
->buffer
= (unsigned char *) obstack_finish (&buffer
);
1053 /* Tell the front-end not to free the buffer after parsing. */
1054 m
->srcfile
->ref
= 1;
1058 /* Handling a D source file, strip off the path and extension. */
1059 const char *basename
= FileName::name (in_fnames
[i
]);
1060 const char *name
= FileName::removeExt (basename
);
1062 Module
*m
= Module::create (in_fnames
[i
], Identifier::idPool (name
),
1063 global
.params
.doDocComments
,
1064 global
.params
.doHdrGeneration
);
1066 FileName::free (name
);
1070 /* Read all D source files. */
1071 for (size_t i
= 0; i
< modules
.length
; i
++)
1073 Module
*m
= modules
[i
];
1077 /* Parse all D source files. */
1078 for (size_t i
= 0; i
< modules
.length
; i
++)
1080 Module
*m
= modules
[i
];
1082 if (global
.params
.verbose
)
1083 message ("parse %s", m
->toChars ());
1085 if (!Module::rootModule
)
1086 Module::rootModule
= m
;
1088 m
->importedFrom
= m
;
1090 Compiler::loadModule (m
);
1095 /* Remove M from list of modules. */
1101 /* Load the module containing D main. */
1102 if (global
.params
.addMain
)
1104 unsigned errors
= global
.startGagging ();
1105 Module
*m
= Module::load (Loc (), NULL
, Identifier::idPool ("__main"));
1107 if (! global
.endGagging (errors
))
1109 m
->importedFrom
= m
;
1117 if (global
.params
.doHdrGeneration
)
1119 /* Generate 'header' import files. Since 'header' import files must be
1120 independent of command line switches and what else is imported, they
1121 are generated before any semantic analysis. */
1122 for (size_t i
= 0; i
< modules
.length
; i
++)
1124 Module
*m
= modules
[i
];
1125 if (d_option
.fonly
&& m
!= Module::rootModule
)
1128 if (global
.params
.verbose
)
1129 message ("import %s", m
->toChars ());
1138 /* Load all unconditional imports for better symbol resolving. */
1139 for (size_t i
= 0; i
< modules
.length
; i
++)
1141 Module
*m
= modules
[i
];
1143 if (global
.params
.verbose
)
1144 message ("importall %s", m
->toChars ());
1146 m
->importAll (NULL
);
1152 /* Do semantic analysis. */
1153 doing_semantic_analysis_p
= true;
1155 for (size_t i
= 0; i
< modules
.length
; i
++)
1157 Module
*m
= modules
[i
];
1159 if (global
.params
.verbose
)
1160 message ("semantic %s", m
->toChars ());
1165 /* Do deferred semantic analysis. */
1166 Module::dprogress
= 1;
1167 Module::runDeferredSemantic ();
1169 if (Module::deferred
.length
)
1171 for (size_t i
= 0; i
< Module::deferred
.length
; i
++)
1173 Dsymbol
*sd
= Module::deferred
[i
];
1174 error_at (make_location_t (sd
->loc
),
1175 "unable to resolve forward reference in definition");
1179 /* Process all built-in modules or functions now for CTFE. */
1180 while (builtin_modules
.length
!= 0)
1182 Module
*m
= builtin_modules
.pop ();
1183 d_maybe_set_builtin (m
);
1186 /* Do pass 2 semantic analysis. */
1187 for (size_t i
= 0; i
< modules
.length
; i
++)
1189 Module
*m
= modules
[i
];
1191 if (global
.params
.verbose
)
1192 message ("semantic2 %s", m
->toChars ());
1194 m
->semantic2 (NULL
);
1197 Module::runDeferredSemantic2 ();
1202 /* Do pass 3 semantic analysis. */
1203 for (size_t i
= 0; i
< modules
.length
; i
++)
1205 Module
*m
= modules
[i
];
1207 if (global
.params
.verbose
)
1208 message ("semantic3 %s", m
->toChars ());
1210 m
->semantic3 (NULL
);
1213 Module::runDeferredSemantic3 ();
1215 /* Check again, incase semantic3 pass loaded any more modules. */
1216 while (builtin_modules
.length
!= 0)
1218 Module
*m
= builtin_modules
.pop ();
1219 d_maybe_set_builtin (m
);
1222 /* Do not attempt to generate output files if errors or warnings occurred. */
1223 if (global
.errors
|| global
.warnings
)
1226 /* Generate output files. */
1227 doing_semantic_analysis_p
= false;
1229 if (Module::rootModule
)
1231 /* Declare the name of the root module as the first global name in order
1232 to make the middle-end fully deterministic. */
1234 mangleToBuffer (Module::rootModule
, &buf
);
1235 first_global_object_name
= buf
.extractString ();
1238 /* Make dependencies. */
1243 for (size_t i
= 0; i
< modules
.length
; i
++)
1244 deps_write (modules
[i
], &buf
);
1246 /* -MF <arg> overrides -M[M]D. */
1247 if (d_option
.deps_filename_user
)
1248 d_option
.deps_filename
= d_option
.deps_filename_user
;
1250 if (d_option
.deps_filename
)
1252 File
*fdeps
= File::create (d_option
.deps_filename
);
1253 fdeps
->setbuffer ((void *) buf
.data
, buf
.offset
);
1255 writeFile (Loc (), fdeps
);
1258 message ("%.*s", (int) buf
.offset
, (char *) buf
.data
);
1261 /* Generate JSON files. */
1262 if (global
.params
.doJsonGeneration
)
1265 json_generate (&buf
, &modules
);
1267 const char *name
= global
.params
.jsonfilename
;
1269 if (name
&& (name
[0] != '-' || name
[1] != '\0'))
1271 const char *nameext
= FileName::defaultExt (name
, global
.json_ext
);
1272 File
*fjson
= File::create (nameext
);
1273 fjson
->setbuffer ((void *) buf
.data
, buf
.offset
);
1275 writeFile (Loc (), fjson
);
1278 message ("%.*s", (int) buf
.offset
, (char *) buf
.data
);
1281 /* Generate Ddoc files. */
1282 if (global
.params
.doDocComments
&& !global
.errors
&& !errorcount
)
1284 for (size_t i
= 0; i
< modules
.length
; i
++)
1286 Module
*m
= modules
[i
];
1291 /* Handle -fdump-d-original. */
1292 if (global
.params
.vcg_ast
)
1294 for (size_t i
= 0; i
< modules
.length
; i
++)
1296 Module
*m
= modules
[i
];
1300 moduleToBuffer (&buf
, m
);
1301 message ("%.*s", (int) buf
.offset
, (char *) buf
.data
);
1305 for (size_t i
= 0; i
< modules
.length
; i
++)
1307 Module
*m
= modules
[i
];
1308 if (d_option
.fonly
&& m
!= Module::rootModule
)
1311 if (global
.params
.verbose
)
1312 message ("code %s", m
->toChars ());
1314 if (!flag_syntax_only
)
1316 if ((entrypoint_module
!= NULL
) && (m
== entrypoint_root_module
))
1317 build_decl_tree (entrypoint_module
);
1319 build_decl_tree (m
);
1323 /* And end the main input file, if the debug writer wants it. */
1324 if (debug_hooks
->start_end_main_source_file
)
1325 debug_hooks
->end_source_file (0);
1328 /* Add the D frontend error count to the GCC error count to correctly
1329 exit with an error status. */
1330 errorcount
+= (global
.errors
+ global
.warnings
);
1332 /* Write out globals. */
1333 d_finish_compilation (vec_safe_address (global_declarations
),
1334 vec_safe_length (global_declarations
));
1337 /* Implements the lang_hooks.types.type_for_mode routine for language D. */
1340 d_type_for_mode (machine_mode mode
, int unsignedp
)
1343 return unsignedp
? d_ubyte_type
: d_byte_type
;
1346 return unsignedp
? d_ushort_type
: d_short_type
;
1349 return unsignedp
? d_uint_type
: d_int_type
;
1352 return unsignedp
? d_ulong_type
: d_long_type
;
1354 if (mode
== TYPE_MODE (d_cent_type
))
1355 return unsignedp
? d_ucent_type
: d_cent_type
;
1357 if (mode
== TYPE_MODE (float_type_node
))
1358 return float_type_node
;
1360 if (mode
== TYPE_MODE (double_type_node
))
1361 return double_type_node
;
1363 if (mode
== TYPE_MODE (long_double_type_node
))
1364 return long_double_type_node
;
1366 if (mode
== TYPE_MODE (build_pointer_type (char8_type_node
)))
1367 return build_pointer_type (char8_type_node
);
1369 if (mode
== TYPE_MODE (build_pointer_type (d_int_type
)))
1370 return build_pointer_type (d_int_type
);
1372 for (int i
= 0; i
< NUM_INT_N_ENTS
; i
++)
1374 if (int_n_enabled_p
[i
] && mode
== int_n_data
[i
].m
)
1377 return int_n_trees
[i
].unsigned_type
;
1379 return int_n_trees
[i
].signed_type
;
1383 if (COMPLEX_MODE_P (mode
))
1385 machine_mode inner_mode
;
1388 if (mode
== TYPE_MODE (complex_float_type_node
))
1389 return complex_float_type_node
;
1390 if (mode
== TYPE_MODE (complex_double_type_node
))
1391 return complex_double_type_node
;
1392 if (mode
== TYPE_MODE (complex_long_double_type_node
))
1393 return complex_long_double_type_node
;
1395 inner_mode
= (machine_mode
) GET_MODE_INNER (mode
);
1396 inner_type
= d_type_for_mode (inner_mode
, unsignedp
);
1397 if (inner_type
!= NULL_TREE
)
1398 return build_complex_type (inner_type
);
1400 else if (VECTOR_MODE_P (mode
))
1402 machine_mode inner_mode
= (machine_mode
) GET_MODE_INNER (mode
);
1403 tree inner_type
= d_type_for_mode (inner_mode
, unsignedp
);
1404 if (inner_type
!= NULL_TREE
)
1405 return build_vector_type_for_mode (inner_type
, mode
);
1411 /* Implements the lang_hooks.types.type_for_size routine for language D. */
1414 d_type_for_size (unsigned bits
, int unsignedp
)
1416 if (bits
<= TYPE_PRECISION (d_byte_type
))
1417 return unsignedp
? d_ubyte_type
: d_byte_type
;
1419 if (bits
<= TYPE_PRECISION (d_short_type
))
1420 return unsignedp
? d_ushort_type
: d_short_type
;
1422 if (bits
<= TYPE_PRECISION (d_int_type
))
1423 return unsignedp
? d_uint_type
: d_int_type
;
1425 if (bits
<= TYPE_PRECISION (d_long_type
))
1426 return unsignedp
? d_ulong_type
: d_long_type
;
1428 if (bits
<= TYPE_PRECISION (d_cent_type
))
1429 return unsignedp
? d_ucent_type
: d_cent_type
;
1431 for (int i
= 0; i
< NUM_INT_N_ENTS
; i
++)
1433 if (int_n_enabled_p
[i
] && bits
== int_n_data
[i
].bitsize
)
1436 return int_n_trees
[i
].unsigned_type
;
1438 return int_n_trees
[i
].signed_type
;
1445 /* Return the signed or unsigned version of TYPE, an integral type, the
1446 signedness being specified by UNSIGNEDP. */
1449 d_signed_or_unsigned_type (int unsignedp
, tree type
)
1451 if (TYPE_UNSIGNED (type
) == (unsigned) unsignedp
)
1454 if (TYPE_PRECISION (type
) == TYPE_PRECISION (d_cent_type
))
1455 return unsignedp
? d_ucent_type
: d_cent_type
;
1457 if (TYPE_PRECISION (type
) == TYPE_PRECISION (d_long_type
))
1458 return unsignedp
? d_ulong_type
: d_long_type
;
1460 if (TYPE_PRECISION (type
) == TYPE_PRECISION (d_int_type
))
1461 return unsignedp
? d_uint_type
: d_int_type
;
1463 if (TYPE_PRECISION (type
) == TYPE_PRECISION (d_short_type
))
1464 return unsignedp
? d_ushort_type
: d_short_type
;
1466 if (TYPE_PRECISION (type
) == TYPE_PRECISION (d_byte_type
))
1467 return unsignedp
? d_ubyte_type
: d_byte_type
;
1469 return signed_or_unsigned_type_for (unsignedp
, type
);
1472 /* Return the unsigned version of TYPE, an integral type. */
1475 d_unsigned_type (tree type
)
1477 return d_signed_or_unsigned_type (1, type
);
1480 /* Return the signed version of TYPE, an integral type. */
1483 d_signed_type (tree type
)
1485 return d_signed_or_unsigned_type (0, type
);
1488 /* Implements the lang_hooks.types.type_promotes_to routine for language D.
1489 All promotions for variable arguments are handled by the D frontend. */
1492 d_type_promotes_to (tree type
)
1497 /* Implements the lang_hooks.decls.global_bindings_p routine for language D.
1498 Return true if we are in the global binding level. */
1501 d_global_bindings_p (void)
1503 return (current_binding_level
== global_binding_level
);
1506 /* Return global_context, but create it first if need be. */
1509 get_global_context (void)
1511 if (!global_context
)
1513 global_context
= build_translation_unit_decl (NULL_TREE
);
1514 debug_hooks
->register_main_translation_unit (global_context
);
1517 return global_context
;
1520 /* Implements the lang_hooks.decls.pushdecl routine for language D.
1521 Record DECL as belonging to the current lexical scope. */
1524 d_pushdecl (tree decl
)
1526 /* Set the context of the decl. If current_function_decl did not help in
1527 determining the context, use global scope. */
1528 if (!DECL_CONTEXT (decl
))
1530 if (current_function_decl
)
1531 DECL_CONTEXT (decl
) = current_function_decl
;
1533 DECL_CONTEXT (decl
) = get_global_context ();
1536 /* Put decls on list in reverse order. */
1537 if (TREE_STATIC (decl
) || d_global_bindings_p ())
1538 vec_safe_push (global_declarations
, decl
);
1541 TREE_CHAIN (decl
) = current_binding_level
->names
;
1542 current_binding_level
->names
= decl
;
1548 /* Implements the lang_hooks.decls.getdecls routine for language D.
1549 Return the list of declarations of the current level. */
1554 if (current_binding_level
)
1555 return current_binding_level
->names
;
1561 /* Implements the lang_hooks.get_alias_set routine for language D.
1562 Get the alias set corresponding to type or expression T.
1563 Return -1 if we don't do anything special. */
1565 static alias_set_type
1566 d_get_alias_set (tree
)
1568 /* For now in D, assume everything aliases everything else, until we define
1569 some solid rules backed by a specification. There are also some parts
1570 of code generation routines that don't adhere to C alias rules, such as
1571 build_vconvert. In any case, a lot of user code already assumes there
1572 is no strict aliasing and will break if we were to change that. */
1576 /* Implements the lang_hooks.types_compatible_p routine for language D.
1577 Compares two types for equivalence in the D programming language.
1578 This routine should only return 1 if it is sure, even though the frontend
1579 should have already ensured that all types are compatible before handing
1580 over the parsed ASTs to the code generator. */
1583 d_types_compatible_p (tree x
, tree y
)
1585 Type
*tx
= TYPE_LANG_FRONTEND (x
);
1586 Type
*ty
= TYPE_LANG_FRONTEND (y
);
1588 /* Try validating the types in the frontend. */
1589 if (tx
!= NULL
&& ty
!= NULL
)
1591 /* Types are equivalent. */
1592 if (same_type_p (tx
, ty
))
1595 /* Type system allows implicit conversion between. */
1596 if (tx
->implicitConvTo (ty
) || ty
->implicitConvTo (tx
))
1600 /* Fallback on using type flags for comparison. E.g: all dynamic arrays
1601 are distinct types in D, but are VIEW_CONVERT compatible. */
1602 if (TREE_CODE (x
) == RECORD_TYPE
&& TREE_CODE (y
) == RECORD_TYPE
)
1604 if (TYPE_DYNAMIC_ARRAY (x
) && TYPE_DYNAMIC_ARRAY (y
))
1607 if (TYPE_DELEGATE (x
) && TYPE_DELEGATE (y
))
1610 if (TYPE_ASSOCIATIVE_ARRAY (x
) && TYPE_ASSOCIATIVE_ARRAY (y
))
1617 /* Implements the lang_hooks.finish_incomplete_decl routine for language D. */
1620 d_finish_incomplete_decl (tree decl
)
1624 /* D allows zero-length declarations. Such a declaration ends up with
1625 DECL_SIZE (t) == NULL_TREE which is what the back-end function
1626 assembler_variable checks. This could change in later versions, or
1627 maybe all of these variables should be aliased to one symbol. */
1628 if (DECL_SIZE (decl
) == 0)
1630 DECL_SIZE (decl
) = bitsize_zero_node
;
1631 DECL_SIZE_UNIT (decl
) = size_zero_node
;
1636 /* Implements the lang_hooks.types.classify_record routine for language D.
1637 Return the true debug type for TYPE. */
1639 static classify_record
1640 d_classify_record (tree type
)
1642 Type
*t
= TYPE_LANG_FRONTEND (type
);
1644 if (t
&& t
->ty
== Tclass
)
1646 TypeClass
*tc
= (TypeClass
*) t
;
1648 /* extern(C++) interfaces get emitted as classes. */
1649 if (tc
->sym
->isInterfaceDeclaration ()
1650 && !tc
->sym
->isCPPinterface ())
1651 return RECORD_IS_INTERFACE
;
1653 return RECORD_IS_CLASS
;
1656 return RECORD_IS_STRUCT
;
1659 /* Implements the lang_hooks.tree_size routine for language D.
1660 Determine the size of our tcc_constant or tcc_exceptional nodes. */
1663 d_tree_size (tree_code code
)
1667 case FUNCFRAME_INFO
:
1668 return sizeof (tree_frame_info
);
1675 /* Implements the lang_hooks.print_xnode routine for language D. */
1678 d_print_xnode (FILE *file
, tree node
, int indent
)
1680 switch (TREE_CODE (node
))
1682 case FUNCFRAME_INFO
:
1683 print_node (file
, "frame_type", FRAMEINFO_TYPE (node
), indent
+ 4);
1691 /* Return which tree structure is used by NODE, or TS_D_GENERIC if NODE
1692 is one of the language-independent trees. */
1694 d_tree_node_structure_enum
1695 d_tree_node_structure (lang_tree_node
*t
)
1697 switch (TREE_CODE (&t
->generic
))
1699 case IDENTIFIER_NODE
:
1700 return TS_D_IDENTIFIER
;
1702 case FUNCFRAME_INFO
:
1703 return TS_D_FRAMEINFO
;
1706 return TS_D_GENERIC
;
1710 /* Allocate and return a lang specific structure for the frontend type. */
1713 build_lang_type (Type
*t
)
1715 struct lang_type
*lt
= ggc_cleared_alloc
<struct lang_type
> ();
1720 /* Allocate and return a lang specific structure for the frontend decl. */
1723 build_lang_decl (Declaration
*d
)
1725 /* For compiler generated run-time typeinfo, a lang_decl is allocated even if
1726 there's no associated frontend symbol to refer to (yet). If the symbol
1727 appears later in the compilation, then the slot will be re-used. */
1729 return ggc_cleared_alloc
<struct lang_decl
> ();
1731 struct lang_decl
*ld
= (d
->csym
) ? DECL_LANG_SPECIFIC (d
->csym
) : NULL
;
1733 ld
= ggc_cleared_alloc
<struct lang_decl
> ();
1735 if (ld
->decl
== NULL
)
1741 /* Implements the lang_hooks.dup_lang_specific_decl routine for language D.
1742 Replace the DECL_LANG_SPECIFIC field of NODE with a copy. */
1745 d_dup_lang_specific_decl (tree node
)
1747 if (! DECL_LANG_SPECIFIC (node
))
1750 struct lang_decl
*ld
= ggc_alloc
<struct lang_decl
> ();
1751 memcpy (ld
, DECL_LANG_SPECIFIC (node
), sizeof (struct lang_decl
));
1752 DECL_LANG_SPECIFIC (node
) = ld
;
1755 /* This preserves trees we create from the garbage collector. */
1757 static GTY(()) tree d_keep_list
= NULL_TREE
;
1762 d_keep_list
= tree_cons (NULL_TREE
, t
, d_keep_list
);
1765 /* Implements the lang_hooks.eh_personality routine for language D.
1766 Return the GDC personality function decl. */
1768 static GTY(()) tree d_eh_personality_decl
;
1771 d_eh_personality (void)
1773 if (!d_eh_personality_decl
)
1774 d_eh_personality_decl
= build_personality_function ("gdc");
1776 return d_eh_personality_decl
;
1779 /* Implements the lang_hooks.eh_runtime_type routine for language D. */
1782 d_build_eh_runtime_type (tree type
)
1784 Type
*t
= TYPE_LANG_FRONTEND (type
);
1787 t
= t
->toBasetype ();
1789 gcc_assert (t
!= NULL
&& t
->ty
== Tclass
);
1790 ClassDeclaration
*cd
= ((TypeClass
*) t
)->sym
;
1793 if (cd
->isCPPclass ())
1794 decl
= get_cpp_typeinfo_decl (cd
);
1796 decl
= get_classinfo_decl (cd
);
1798 return convert (ptr_type_node
, build_address (decl
));
1801 /* Definitions for our language-specific hooks. */
1803 #undef LANG_HOOKS_NAME
1804 #undef LANG_HOOKS_INIT
1805 #undef LANG_HOOKS_INIT_TS
1806 #undef LANG_HOOKS_INIT_OPTIONS
1807 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
1808 #undef LANG_HOOKS_OPTION_LANG_MASK
1809 #undef LANG_HOOKS_HANDLE_OPTION
1810 #undef LANG_HOOKS_POST_OPTIONS
1811 #undef LANG_HOOKS_PARSE_FILE
1812 #undef LANG_HOOKS_COMMON_ATTRIBUTE_TABLE
1813 #undef LANG_HOOKS_ATTRIBUTE_TABLE
1814 #undef LANG_HOOKS_GET_ALIAS_SET
1815 #undef LANG_HOOKS_TYPES_COMPATIBLE_P
1816 #undef LANG_HOOKS_BUILTIN_FUNCTION
1817 #undef LANG_HOOKS_REGISTER_BUILTIN_TYPE
1818 #undef LANG_HOOKS_FINISH_INCOMPLETE_DECL
1819 #undef LANG_HOOKS_GIMPLIFY_EXPR
1820 #undef LANG_HOOKS_CLASSIFY_RECORD
1821 #undef LANG_HOOKS_TREE_SIZE
1822 #undef LANG_HOOKS_PRINT_XNODE
1823 #undef LANG_HOOKS_DUP_LANG_SPECIFIC_DECL
1824 #undef LANG_HOOKS_EH_PERSONALITY
1825 #undef LANG_HOOKS_EH_RUNTIME_TYPE
1826 #undef LANG_HOOKS_PUSHDECL
1827 #undef LANG_HOOKS_GETDECLS
1828 #undef LANG_HOOKS_GLOBAL_BINDINGS_P
1829 #undef LANG_HOOKS_TYPE_FOR_MODE
1830 #undef LANG_HOOKS_TYPE_FOR_SIZE
1831 #undef LANG_HOOKS_TYPE_PROMOTES_TO
1833 #define LANG_HOOKS_NAME "GNU D"
1834 #define LANG_HOOKS_INIT d_init
1835 #define LANG_HOOKS_INIT_TS d_init_ts
1836 #define LANG_HOOKS_INIT_OPTIONS d_init_options
1837 #define LANG_HOOKS_INIT_OPTIONS_STRUCT d_init_options_struct
1838 #define LANG_HOOKS_OPTION_LANG_MASK d_option_lang_mask
1839 #define LANG_HOOKS_HANDLE_OPTION d_handle_option
1840 #define LANG_HOOKS_POST_OPTIONS d_post_options
1841 #define LANG_HOOKS_PARSE_FILE d_parse_file
1842 #define LANG_HOOKS_COMMON_ATTRIBUTE_TABLE d_langhook_common_attribute_table
1843 #define LANG_HOOKS_ATTRIBUTE_TABLE d_langhook_attribute_table
1844 #define LANG_HOOKS_GET_ALIAS_SET d_get_alias_set
1845 #define LANG_HOOKS_TYPES_COMPATIBLE_P d_types_compatible_p
1846 #define LANG_HOOKS_BUILTIN_FUNCTION d_builtin_function
1847 #define LANG_HOOKS_REGISTER_BUILTIN_TYPE d_register_builtin_type
1848 #define LANG_HOOKS_FINISH_INCOMPLETE_DECL d_finish_incomplete_decl
1849 #define LANG_HOOKS_GIMPLIFY_EXPR d_gimplify_expr
1850 #define LANG_HOOKS_CLASSIFY_RECORD d_classify_record
1851 #define LANG_HOOKS_TREE_SIZE d_tree_size
1852 #define LANG_HOOKS_PRINT_XNODE d_print_xnode
1853 #define LANG_HOOKS_DUP_LANG_SPECIFIC_DECL d_dup_lang_specific_decl
1854 #define LANG_HOOKS_EH_PERSONALITY d_eh_personality
1855 #define LANG_HOOKS_EH_RUNTIME_TYPE d_build_eh_runtime_type
1856 #define LANG_HOOKS_PUSHDECL d_pushdecl
1857 #define LANG_HOOKS_GETDECLS d_getdecls
1858 #define LANG_HOOKS_GLOBAL_BINDINGS_P d_global_bindings_p
1859 #define LANG_HOOKS_TYPE_FOR_MODE d_type_for_mode
1860 #define LANG_HOOKS_TYPE_FOR_SIZE d_type_for_size
1861 #define LANG_HOOKS_TYPE_PROMOTES_TO d_type_promotes_to
1863 struct lang_hooks lang_hooks
= LANG_HOOKS_INITIALIZER
;
1865 #include "gt-d-d-lang.h"
1866 #include "gtype-d.h"