d: Merge upstream dmd ff57fec515, druntime ff57fec515, phobos 17bafda79.
[official-gcc.git] / gcc / d / dmd / astenums.d
blob6a9c0104a7270e3a8fb53e5c3e35106000276983
1 /**
2 * Defines enums common to dmd and dmd as parse library.
4 * Copyright: Copyright (C) 1999-2023 by The D Language Foundation, All Rights Reserved
5 * License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
6 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/astenums.d, _astenums.d)
7 * Documentation: https://dlang.org/phobos/dmd_astenums.html
8 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/astenums.d
9 */
11 module dmd.astenums;
13 enum Sizeok : ubyte
15 none, /// size of aggregate is not yet able to compute
16 fwd, /// size of aggregate is ready to compute
17 inProcess, /// in the midst of computing the size
18 done, /// size of aggregate is set correctly
21 enum Baseok : ubyte
23 none, /// base classes not computed yet
24 start, /// in process of resolving base classes
25 done, /// all base classes are resolved
26 semanticdone, /// all base classes semantic done
29 enum MODFlags : int
31 none = 0, // default (mutable)
32 const_ = 1, // type is const
33 immutable_ = 4, // type is immutable
34 shared_ = 2, // type is shared
35 wild = 8, // type is wild
36 wildconst = (MODFlags.wild | MODFlags.const_), // type is wild const
37 mutable = 0x10, // type is mutable (only used in wildcard matching)
40 alias MOD = ubyte;
42 enum STC : ulong // transfer changes to declaration.h
44 undefined_ = 0,
46 static_ = 1, /// `static`
47 extern_ = 2, /// `extern`
48 const_ = 4, /// `const`
49 final_ = 8, /// `final`
51 abstract_ = 0x10, /// `abstract`
52 parameter = 0x20, /// is function parameter
53 field = 0x40, /// is field of struct, union or class
54 override_ = 0x80, /// `override`
56 auto_ = 0x100, /// `auto`
57 synchronized_ = 0x200, /// `synchronized`
58 deprecated_ = 0x400, /// `deprecated`
59 in_ = 0x800, /// `in` parameter
61 out_ = 0x1000, /// `out` parameter
62 lazy_ = 0x2000, /// `lazy` parameter
63 foreach_ = 0x4000, /// variable for foreach loop
64 variadic = 0x8000, /// the `variadic` parameter in: T foo(T a, U b, V variadic...)
66 // = 0x1_0000,
67 templateparameter = 0x2_0000, /// template parameter
68 ref_ = 0x4_0000, /// `ref`
69 scope_ = 0x8_0000, /// `scope`
71 scopeinferred = 0x20_0000, /// `scope` has been inferred and should not be part of mangling, `scope_` must also be set
72 return_ = 0x40_0000, /// 'return ref' or 'return scope' for function parameters
73 returnScope = 0x80_0000, /// if `ref return scope` then resolve to `ref` and `return scope`
75 returninferred = 0x100_0000, /// `return` has been inferred and should not be part of mangling, `return_` must also be set
76 immutable_ = 0x200_0000, /// `immutable`
77 // = 0x400_0000,
78 manifest = 0x800_0000, /// manifest constant
80 nodtor = 0x1000_0000, /// do not run destructor
81 nothrow_ = 0x2000_0000, /// `nothrow` meaning never throws exceptions
82 pure_ = 0x4000_0000, /// `pure` function
83 tls = 0x8000_0000, /// thread local
85 alias_ = 0x1_0000_0000, /// `alias` parameter
86 shared_ = 0x2_0000_0000, /// accessible from multiple threads
87 gshared = 0x4_0000_0000, /// accessible from multiple threads, but not typed as `shared`
88 wild = 0x8_0000_0000, /// for wild type constructor
90 property = 0x10_0000_0000, /// `@property`
91 safe = 0x20_0000_0000, /// `@safe`
92 trusted = 0x40_0000_0000, /// `@trusted`
93 system = 0x80_0000_0000, /// `@system`
95 ctfe = 0x100_0000_0000, /// can be used in CTFE, even if it is static
96 disable = 0x200_0000_0000, /// for functions that are not callable
97 result = 0x400_0000_0000, /// for result variables passed to out contracts
98 nodefaultctor = 0x800_0000_0000, /// must be set inside constructor
100 temp = 0x1000_0000_0000, /// temporary variable
101 rvalue = 0x2000_0000_0000, /// force rvalue for variables
102 nogc = 0x4000_0000_0000, /// `@nogc`
103 autoref = 0x8000_0000_0000, /// Mark for the already deduced `auto ref` parameter
105 inference = 0x1_0000_0000_0000, /// do attribute inference
106 exptemp = 0x2_0000_0000_0000, /// temporary variable that has lifetime restricted to an expression
107 future = 0x4_0000_0000_0000, /// introducing new base class function
108 local = 0x8_0000_0000_0000, /// do not forward (see dmd.dsymbol.ForwardingScopeDsymbol).
110 live = 0x10_0000_0000_0000, /// function `@live` attribute
111 register = 0x20_0000_0000_0000, /// `register` storage class (ImportC)
112 volatile_ = 0x40_0000_0000_0000, /// destined for volatile in the back end
114 safeGroup = STC.safe | STC.trusted | STC.system,
115 IOR = STC.in_ | STC.ref_ | STC.out_,
116 TYPECTOR = (STC.const_ | STC.immutable_ | STC.shared_ | STC.wild),
117 FUNCATTR = (STC.ref_ | STC.nothrow_ | STC.nogc | STC.pure_ | STC.property | STC.live |
118 safeGroup),
120 /* These are visible to the user, i.e. are expressed by the user
122 visibleStorageClasses =
123 (STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ | STC.const_ | STC.final_ | STC.abstract_ | STC.synchronized_ |
124 STC.deprecated_ | STC.future | STC.override_ | STC.lazy_ | STC.alias_ | STC.out_ | STC.in_ | STC.manifest |
125 STC.immutable_ | STC.shared_ | STC.wild | STC.nothrow_ | STC.nogc | STC.pure_ | STC.ref_ | STC.return_ | STC.tls | STC.gshared |
126 STC.property | STC.safeGroup | STC.disable | STC.local | STC.live),
128 /* These storage classes "flow through" to the inner scope of a Dsymbol
130 flowThruAggregate = STC.safeGroup, /// for an AggregateDeclaration
131 flowThruFunction = ~(STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ | STC.abstract_ | STC.deprecated_ | STC.override_ |
132 STC.TYPECTOR | STC.final_ | STC.tls | STC.gshared | STC.ref_ | STC.return_ | STC.property |
133 STC.nothrow_ | STC.pure_ | STC.safe | STC.trusted | STC.system), /// for a FuncDeclaration
137 alias StorageClass = ulong;
139 /********
140 * Determine if it's the ambigous case of where `return` attaches to.
141 * Params:
142 * stc = STC flags
143 * Returns:
144 * true if (`ref` | `out`) and `scope` and `return`
146 @safe pure @nogc nothrow
147 bool isRefReturnScope(const ulong stc)
149 return (stc & (STC.scope_ | STC.return_)) == (STC.scope_ | STC.return_) &&
150 stc & (STC.ref_ | STC.out_);
153 /* This is different from the one in declaration.d, make that fix a separate PR */
154 static if (0)
155 extern (C++) __gshared const(StorageClass) STCStorageClass =
156 (STC.auto_ | STC.scope_ | STC.static_ | STC.extern_ | STC.const_ | STC.final_ |
157 STC.abstract_ | STC.synchronized_ | STC.deprecated_ | STC.override_ | STC.lazy_ |
158 STC.alias_ | STC.out_ | STC.in_ | STC.manifest | STC.immutable_ | STC.shared_ |
159 STC.wild | STC.nothrow_ | STC.nogc | STC.pure_ | STC.ref_ | STC.return_ | STC.tls |
160 STC.gshared | STC.property | STC.live |
161 STC.safeGroup | STC.disable);
163 enum TY : ubyte
165 Tarray, // slice array, aka T[]
166 Tsarray, // static array, aka T[dimension]
167 Taarray, // associative array, aka T[type]
168 Tpointer,
169 Treference,
170 Tfunction,
171 Tident,
172 Tclass,
173 Tstruct,
174 Tenum,
176 Tdelegate,
177 Tnone,
178 Tvoid,
179 Tint8,
180 Tuns8,
181 Tint16,
182 Tuns16,
183 Tint32,
184 Tuns32,
185 Tint64,
187 Tuns64,
188 Tfloat32,
189 Tfloat64,
190 Tfloat80,
191 Timaginary32,
192 Timaginary64,
193 Timaginary80,
194 Tcomplex32,
195 Tcomplex64,
196 Tcomplex80,
198 Tbool,
199 Tchar,
200 Twchar,
201 Tdchar,
202 Terror,
203 Tinstance,
204 Ttypeof,
205 Ttuple,
206 Tslice,
207 Treturn,
209 Tnull,
210 Tvector,
211 Tint128,
212 Tuns128,
213 Ttraits,
214 Tmixin,
215 Tnoreturn,
216 Ttag,
218 enum TMAX = TY.max + 1;
220 alias Tarray = TY.Tarray;
221 alias Tsarray = TY.Tsarray;
222 alias Taarray = TY.Taarray;
223 alias Tpointer = TY.Tpointer;
224 alias Treference = TY.Treference;
225 alias Tfunction = TY.Tfunction;
226 alias Tident = TY.Tident;
227 alias Tclass = TY.Tclass;
228 alias Tstruct = TY.Tstruct;
229 alias Tenum = TY.Tenum;
230 alias Tdelegate = TY.Tdelegate;
231 alias Tnone = TY.Tnone;
232 alias Tvoid = TY.Tvoid;
233 alias Tint8 = TY.Tint8;
234 alias Tuns8 = TY.Tuns8;
235 alias Tint16 = TY.Tint16;
236 alias Tuns16 = TY.Tuns16;
237 alias Tint32 = TY.Tint32;
238 alias Tuns32 = TY.Tuns32;
239 alias Tint64 = TY.Tint64;
240 alias Tuns64 = TY.Tuns64;
241 alias Tfloat32 = TY.Tfloat32;
242 alias Tfloat64 = TY.Tfloat64;
243 alias Tfloat80 = TY.Tfloat80;
244 alias Timaginary32 = TY.Timaginary32;
245 alias Timaginary64 = TY.Timaginary64;
246 alias Timaginary80 = TY.Timaginary80;
247 alias Tcomplex32 = TY.Tcomplex32;
248 alias Tcomplex64 = TY.Tcomplex64;
249 alias Tcomplex80 = TY.Tcomplex80;
250 alias Tbool = TY.Tbool;
251 alias Tchar = TY.Tchar;
252 alias Twchar = TY.Twchar;
253 alias Tdchar = TY.Tdchar;
254 alias Terror = TY.Terror;
255 alias Tinstance = TY.Tinstance;
256 alias Ttypeof = TY.Ttypeof;
257 alias Ttuple = TY.Ttuple;
258 alias Tslice = TY.Tslice;
259 alias Treturn = TY.Treturn;
260 alias Tnull = TY.Tnull;
261 alias Tvector = TY.Tvector;
262 alias Tint128 = TY.Tint128;
263 alias Tuns128 = TY.Tuns128;
264 alias Ttraits = TY.Ttraits;
265 alias Tmixin = TY.Tmixin;
266 alias Tnoreturn = TY.Tnoreturn;
267 alias Ttag = TY.Ttag;
269 enum TFlags
271 integral = 1,
272 floating = 2,
273 unsigned = 4,
274 real_ = 8,
275 imaginary = 0x10,
276 complex = 0x20,
279 enum PKG : int
281 unknown, /// not yet determined whether it's a package.d or not
282 module_, /// already determined that's an actual package.d
283 package_, /// already determined that's an actual package
286 enum ThreeState : ubyte
288 none, /// state is not yet computed
289 no, /// state is false
290 yes, /// state is true
293 enum TRUST : ubyte
295 default_ = 0,
296 system = 1, // @system (same as TRUST.default)
297 trusted = 2, // @trusted
298 safe = 3, // @safe
301 enum PURE : ubyte
303 impure = 0, // not pure at all
304 fwdref = 1, // it's pure, but not known which level yet
305 weak = 2, // no mutable globals are read or written
306 const_ = 3, // parameters are values or const = strongly pure
309 // Whether alias this dependency is recursive or not
310 enum AliasThisRec : int
312 no = 0, // no alias this recursion
313 yes = 1, // alias this has recursive dependency
314 fwdref = 2, // not yet known
315 typeMask = 3, // mask to read no/yes/fwdref
316 tracing = 0x4, // mark in progress of implicitConvTo/deduceWild
317 tracingDT = 0x8, // mark in progress of deduceType
320 /***************
321 * Variadic argument lists
322 * https://dlang.org/spec/function.html#variadic
324 enum VarArg : ubyte
326 none = 0, /// fixed number of arguments
327 variadic = 1, /// (T t, ...) can be C-style (core.stdc.stdarg) or D-style (core.vararg)
328 typesafe = 2, /// (T t ...) typesafe https://dlang.org/spec/function.html#typesafe_variadic_functions
329 /// or https://dlang.org/spec/function.html#typesafe_variadic_functions
330 KRvariadic = 3, /// K+R C style variadics (no function prototype)
333 /*************************
334 * Identify Statement types with this enum rather than
335 * virtual functions
337 enum STMT : ubyte
339 Error,
340 Peel,
341 Exp, DtorExp,
342 Mixin,
343 Compound, CompoundDeclaration, CompoundAsm,
344 UnrolledLoop,
345 Scope,
346 Forwarding,
347 While,
349 For,
350 Foreach,
351 ForeachRange,
353 Conditional,
354 StaticForeach,
355 Pragma,
356 StaticAssert,
357 Switch,
358 Case,
359 CaseRange,
360 Default,
361 GotoDefault,
362 GotoCase,
363 SwitchError,
364 Return,
365 Break,
366 Continue,
367 Synchronized,
368 With,
369 TryCatch,
370 TryFinally,
371 ScopeGuard,
372 Throw,
373 Debug,
374 Goto,
375 Label,
376 Asm, InlineAsm, GccAsm,
377 Import,
380 /**********************
381 * Discriminant for which kind of initializer
383 enum InitKind : ubyte
385 void_,
386 default_,
387 error,
388 struct_,
389 array,
390 exp,
394 /// A linkage attribute as defined by `extern(XXX)`
396 /// https://dlang.org/spec/attribute.html#linkage
397 enum LINK : ubyte
399 default_,
402 cpp,
403 windows,
404 objc,
405 system,
408 /// Whether to mangle an external aggregate as a struct or class, as set by `extern(C++, struct)`
409 enum CPPMANGLE : ubyte
411 def, /// default
412 asStruct, /// `extern(C++, struct)`
413 asClass, /// `extern(C++, class)`
416 /// Function match levels
418 /// https://dlang.org/spec/function.html#function-overloading
419 enum MATCH : int
421 nomatch, /// no match
422 convert, /// match with conversions
423 constant, /// match with conversion to const
424 exact, /// exact match
427 /// Inline setting as defined by `pragma(inline, XXX)`
428 enum PINLINE : ubyte
430 default_, /// as specified on the command line
431 never, /// never inline
432 always, /// always inline
435 /// Source file type
436 enum FileType : ubyte
438 d, /// normal D source file
439 dhdr, /// D header file (.di)
440 ddoc, /// Ddoc documentation file (.dd)
441 c, /// C source file
444 extern (C++) struct structalign_t
446 private:
447 ushort value = 0; // unknown
448 enum STRUCTALIGN_DEFAULT = 1234; // default = match whatever the corresponding C compiler does
449 bool pack; // use #pragma pack semantics
451 public:
452 pure @safe @nogc nothrow:
453 bool isDefault() const { return value == STRUCTALIGN_DEFAULT; }
454 void setDefault() { value = STRUCTALIGN_DEFAULT; }
455 bool isUnknown() const { return value == 0; } // value is not set
456 void setUnknown() { value = 0; }
457 void set(uint value) { this.value = cast(ushort)value; }
458 uint get() const { return value; }
459 bool isPack() const { return pack; }
460 void setPack(bool pack) { this.pack = pack; }