return ParseAssert(nullptr, CurRec);
if (Lex.getCode() == tgtok::Defvar)
- return ParseDefvar();
+ return ParseDefvar(CurRec);
if (Lex.getCode() != tgtok::Let) {
if (!ParseDeclaration(CurRec, false))
///
/// Defvar ::= DEFVAR Id '=' Value ';'
///
-bool TGParser::ParseDefvar() {
+bool TGParser::ParseDefvar(Record *CurRec) {
assert(Lex.getCode() == tgtok::Defvar);
Lex.Lex(); // Eat the 'defvar' token
if (!consume(tgtok::equal))
return TokError("expected '='");
- Init *Value = ParseValue(nullptr);
+ Init *Value = ParseValue(CurRec);
if (!Value)
return true;
bool ParseDefm(MultiClass *CurMultiClass);
bool ParseDef(MultiClass *CurMultiClass);
bool ParseDefset();
- bool ParseDefvar();
+ bool ParseDefvar(Record *CurRec = nullptr);
bool ParseForeach(MultiClass *CurMultiClass);
bool ParseIf(MultiClass *CurMultiClass);
bool ParseIfBody(MultiClass *CurMultiClass, StringRef Kind);
defvar myvar = "another value";
#endif
+// These variables should be overrided by template arguments.
+defvar a = 2333;
+defvar b = 2333;
+class VarScopeTest<int a, int b> {
+ defvar c = !add(a, b);
+ int value = !add(c, c);
+}
+
+// CHECK: def aaa_scope_test {
+// CHECK-NEXT: int value = 10;
+def aaa_scope_test: VarScopeTest<2, 3>;
+
multiclass Test<int x> {
// Refer to a global variable, while inside a local scope like a multiclass.
def _with_global_string { string s = myvar; }