PR libstdc++/87308 adjust regex used in std::any pretty printer
[official-gcc.git] / gcc / d / dmd / scope.h
blobf42a317f24021bc2019be88cd803fcd0641a003b
2 /* Compiler implementation of the D programming language
3 * Copyright (C) 1999-2018 by The D Language Foundation, All Rights Reserved
4 * written by Walter Bright
5 * http://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * http://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/scope.h
9 */
11 #pragma once
13 class Dsymbol;
14 class ScopeDsymbol;
15 class Identifier;
16 class Module;
17 class Statement;
18 class SwitchStatement;
19 class TryFinallyStatement;
20 class LabelStatement;
21 class ForeachStatement;
22 class ClassDeclaration;
23 class AggregateDeclaration;
24 class FuncDeclaration;
25 class UserAttributeDeclaration;
26 struct DocComment;
27 struct AA;
28 class TemplateInstance;
30 #include "dsymbol.h"
32 #if __GNUC__
33 // Requires a full definition for LINK
34 #include "globals.h"
35 #else
36 enum LINK;
37 enum PINLINE;
38 #endif
40 #define CSXthis_ctor 1 // called this()
41 #define CSXsuper_ctor 2 // called super()
42 #define CSXthis 4 // referenced this
43 #define CSXsuper 8 // referenced super
44 #define CSXlabel 0x10 // seen a label
45 #define CSXreturn 0x20 // seen a return statement
46 #define CSXany_ctor 0x40 // either this() or super() was called
47 #define CSXhalt 0x80 // assert(0)
49 // Flags that would not be inherited beyond scope nesting
50 #define SCOPEctor 0x0001 // constructor type
51 #define SCOPEcondition 0x0004 // inside static if/assert condition
52 #define SCOPEdebug 0x0008 // inside debug conditional
54 // Flags that would be inherited beyond scope nesting
55 #define SCOPEnoaccesscheck 0x0002 // don't do access checks
56 #define SCOPEconstraint 0x0010 // inside template constraint
57 #define SCOPEinvariant 0x0020 // inside invariant code
58 #define SCOPErequire 0x0040 // inside in contract code
59 #define SCOPEensure 0x0060 // inside out contract code
60 #define SCOPEcontract 0x0060 // [mask] we're inside contract code
61 #define SCOPEctfe 0x0080 // inside a ctfe-only expression
62 #define SCOPEcompile 0x0100 // inside __traits(compile)
63 #define SCOPEignoresymbolvisibility 0x0200 // ignore symbol visibility (Bugzilla 15907)
64 #define SCOPEfullinst 0x1000 // fully instantiate templates
66 #define SCOPEfree 0x8000 // is on free list
68 struct Scope
70 Scope *enclosing; // enclosing Scope
72 Module *_module; // Root module
73 ScopeDsymbol *scopesym; // current symbol
74 ScopeDsymbol *sds; // if in static if, and declaring new symbols,
75 // sds gets the addMember()
76 FuncDeclaration *func; // function we are in
77 Dsymbol *parent; // parent to use
78 LabelStatement *slabel; // enclosing labelled statement
79 SwitchStatement *sw; // enclosing switch statement
80 TryFinallyStatement *tf; // enclosing try finally statement
81 OnScopeStatement *os; // enclosing scope(xxx) statement
82 Statement *sbreak; // enclosing statement that supports "break"
83 Statement *scontinue; // enclosing statement that supports "continue"
84 ForeachStatement *fes; // if nested function for ForeachStatement, this is it
85 Scope *callsc; // used for __FUNCTION__, __PRETTY_FUNCTION__ and __MODULE__
86 int inunion; // we're processing members of a union
87 int nofree; // set if shouldn't free it
88 int noctor; // set if constructor calls aren't allowed
89 int intypeof; // in typeof(exp)
90 VarDeclaration *lastVar; // Previous symbol used to prevent goto-skips-init
92 /* If minst && !tinst, it's in definitely non-speculative scope (eg. module member scope).
93 * If !minst && !tinst, it's in definitely speculative scope (eg. template constraint).
94 * If minst && tinst, it's in instantiated code scope without speculation.
95 * If !minst && tinst, it's in instantiated code scope with speculation.
97 Module *minst; // root module where the instantiated templates should belong to
98 TemplateInstance *tinst; // enclosing template instance
100 unsigned callSuper; // primitive flow analysis for constructors
101 unsigned *fieldinit;
102 size_t fieldinit_dim;
104 AlignDeclaration *aligndecl; // alignment for struct members
106 LINK linkage; // linkage for external functions
107 CPPMANGLE cppmangle; // C++ mangle type
108 PINLINE inlining; // inlining strategy for functions
110 Prot protection; // protection for class members
111 int explicitProtection; // set if in an explicit protection attribute
113 StorageClass stc; // storage class
115 DeprecatedDeclaration *depdecl; // customized deprecation message
117 unsigned flags;
119 UserAttributeDeclaration *userAttribDecl; // user defined attributes
121 DocComment *lastdc; // documentation comment for last symbol at this scope
122 AA *anchorCounts; // lookup duplicate anchor name count
123 Identifier *prevAnchor; // qualified symbol name of last doc anchor
125 static Scope *freelist;
126 static Scope *alloc();
127 static Scope *createGlobal(Module *module);
129 Scope();
131 Scope *copy();
133 Scope *push();
134 Scope *push(ScopeDsymbol *ss);
135 Scope *pop();
137 Scope *startCTFE();
138 Scope *endCTFE();
140 void mergeCallSuper(Loc loc, unsigned cs);
142 unsigned *saveFieldInit();
143 void mergeFieldInit(Loc loc, unsigned *cses);
145 Module *instantiatingModule();
147 Dsymbol *search(Loc loc, Identifier *ident, Dsymbol **pscopesym, int flags = IgnoreNone);
148 static void deprecation10378(Loc loc, Dsymbol *sold, Dsymbol *snew);
149 Dsymbol *search_correct(Identifier *ident);
150 static const char *search_correct_C(Identifier *ident);
151 Dsymbol *insert(Dsymbol *s);
153 ClassDeclaration *getClassScope();
154 AggregateDeclaration *getStructClassScope();
155 void setNoFree();
157 structalign_t alignment();