C++: Give static_assert's an enclosing element

This commit is contained in:
Ian Lynagh 2020-07-08 15:41:59 +01:00
Родитель 548fceb306
Коммит 71b70b4bd0
2 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -197,7 +197,8 @@ class Element extends ElementBase {
initialisers(underlyingElement(this), unresolveElement(result), _, _) or initialisers(underlyingElement(this), unresolveElement(result), _, _) or
exprconv(unresolveElement(result), underlyingElement(this)) or exprconv(unresolveElement(result), underlyingElement(this)) or
param_decl_bind(underlyingElement(this), _, unresolveElement(result)) or param_decl_bind(underlyingElement(this), _, unresolveElement(result)) or
using_container(unresolveElement(result), underlyingElement(this)) using_container(unresolveElement(result), underlyingElement(this)) or
static_asserts(unresolveElement(this), _, _, _, underlyingElement(result))
} }
/** Gets the closest `Element` enclosing this one. */ /** Gets the closest `Element` enclosing this one. */
@ -278,12 +279,12 @@ class StaticAssert extends Locatable, @static_assert {
/** /**
* Gets the expression which this static assertion ensures is true. * Gets the expression which this static assertion ensures is true.
*/ */
Expr getCondition() { static_asserts(underlyingElement(this), unresolveElement(result), _, _) } Expr getCondition() { static_asserts(underlyingElement(this), unresolveElement(result), _, _, _) }
/** /**
* Gets the message which will be reported by the compiler if this static assertion fails. * Gets the message which will be reported by the compiler if this static assertion fails.
*/ */
string getMessage() { static_asserts(underlyingElement(this), _, result, _) } string getMessage() { static_asserts(underlyingElement(this), _, result, _, _) }
override Location getLocation() { static_asserts(underlyingElement(this), _, _, result) } override Location getLocation() { static_asserts(underlyingElement(this), _, _, result, _) }
} }

Просмотреть файл

@ -508,7 +508,8 @@ static_asserts(
unique int id: @static_assert, unique int id: @static_assert,
int condition : @expr ref, int condition : @expr ref,
string message : string ref, string message : string ref,
int location: @location_default ref int location: @location_default ref,
int enclosing : @element ref
); );
// each function has an ordered list of parameters // each function has an ordered list of parameters