Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/cpp/cpp_static_assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ Author: Daniel Kroening, kroening@cs.cmu.edu
class cpp_static_assertt : public binary_exprt
{
public:
cpp_static_assertt() : binary_exprt(ID_cpp_static_assert)
cpp_static_assertt(exprt _cond, exprt _description)
: binary_exprt(
std::move(_cond),
ID_cpp_static_assert,
std::move(_description),
typet())
{
}

Expand Down
17 changes: 11 additions & 6 deletions src/cpp/parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,19 +920,20 @@ bool Parser::rStaticAssert(cpp_static_assertt &cpp_static_assert)
if(lex.get_token(tk)!=TOK_STATIC_ASSERT)
return false;

cpp_static_assert=cpp_static_assertt();
set_location(cpp_static_assert, tk);

if(lex.get_token(tk)!='(')
return false;

if(!rExpression(cpp_static_assert.cond(), false))
exprt cond;

if(!rExpression(cond, false))
return false;

if(lex.get_token(tk)!=',')
return false;

if(!rExpression(cpp_static_assert.description(), false))
exprt description;

if(!rExpression(description, false))
return false;

if(lex.get_token(tk)!=')')
Expand All @@ -941,6 +942,10 @@ bool Parser::rStaticAssert(cpp_static_assertt &cpp_static_assert)
if(lex.get_token(tk)!=';')
return false;

cpp_static_assert =
cpp_static_assertt(std::move(cond), std::move(description));
set_location(cpp_static_assert, tk);

return true;
}

Expand Down Expand Up @@ -7505,7 +7510,7 @@ optionalt<codet> Parser::rStatement()

case TOK_STATIC_ASSERT:
{
cpp_static_assertt cpp_static_assert;
cpp_static_assertt cpp_static_assert{nil_exprt(), nil_exprt()};

if(!rStaticAssert(cpp_static_assert))
return {};
Expand Down