1 /** 2 * Defines the `Dsymbol` representing a `static assert()`. 3 * 4 * Specification: $(LINK2 https://dlang.org/spec/version.html#static-assert, Static Assert) 5 * 6 * Copyright: Copyright (C) 1999-2021 by The D Language Foundation, All Rights Reserved 7 * Authors: $(LINK2 http://www.digitalmars.com, Walter Bright) 8 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 9 * Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/staticassert.d, _staticassert.d) 10 * Documentation: https://dlang.org/phobos/dmd_staticassert.html 11 * Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/staticassert.d 12 */ 13 14 module dmd.staticassert; 15 16 import dmd.dscope; 17 import dmd.dsymbol; 18 import dmd.expression; 19 import dmd.globals; 20 import dmd.id; 21 import dmd.identifier; 22 import dmd.mtype; 23 import dmd.visitor; 24 25 /*********************************************************** 26 */ 27 extern (C++) final class StaticAssert : Dsymbol 28 { 29 Expression exp; 30 Expression msg; 31 32 extern (D) this(const ref Loc loc, Expression exp, Expression msg) 33 { 34 super(loc, Id.empty); 35 this.exp = exp; 36 this.msg = msg; 37 } 38 39 override StaticAssert syntaxCopy(Dsymbol s) 40 { 41 assert(!s); 42 return new StaticAssert(loc, exp.syntaxCopy(), msg ? msg.syntaxCopy() : null); 43 } 44 45 override void addMember(Scope* sc, ScopeDsymbol sds) 46 { 47 // we didn't add anything 48 } 49 50 override bool oneMember(Dsymbol* ps, Identifier ident) 51 { 52 //printf("StaticAssert::oneMember())\n"); 53 *ps = null; 54 return true; 55 } 56 57 override const(char)* kind() const 58 { 59 return "static assert"; 60 } 61 62 override void accept(Visitor v) 63 { 64 v.visit(this); 65 } 66 }