Skip to content
Snippets Groups Projects
Verified Commit 60f72e96 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Macro processor: gracefully fail when argument to @#ifdef/@#ifndef is not a variable name

Ref. dynare#1771

(cherry picked from commit 4c14dc3f)
parent bfc002a0
No related branches found
No related tags found
No related merge requests found
/*
* Copyright © 2019-2020 Dynare Team
* Copyright © 2019-2021 Dynare Team
*
* This file is part of Dynare.
*
......@@ -253,7 +253,9 @@ If::interpret(ostream &output, vector<filesystem::path> &paths)
{
first_clause = false;
VariablePtr vp = dynamic_pointer_cast<Variable>(expr);
assert(vp);
if (!vp)
error(StackTrace(ifdef ? "@#ifdef" : "@ifndef",
"The condition must be a variable name", location));
if ((ifdef && env.isVariableDefined(vp->getName()))
|| (ifndef && !env.isVariableDefined(vp->getName())))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment