cprover
cpp_typecheck_static_assert.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: C++ Language Type Checking
4 
5 Author: Daniel Kroening, kroening@cs.cmu.edu
6 
7 \*******************************************************************/
8 
11 
12 #include "cpp_typecheck.h"
13 
14 #include <util/std_types.h>
15 #include <util/string_constant.h>
16 
18 {
19  typecheck_expr(cpp_static_assert.op0());
20  typecheck_expr(cpp_static_assert.op1());
21 
22  implicit_typecast_bool(cpp_static_assert.op0());
23  make_constant(cpp_static_assert.op0());
24 
25  if(cpp_static_assert.op0().is_false())
26  {
27  // failed
28  error().source_location=cpp_static_assert.source_location();
29  error() << "static assertion failed";
30  if(cpp_static_assert.op1().id()==ID_string_constant)
31  error() << ": "
32  << to_string_constant(cpp_static_assert.op1()).get_value();
33  error() << eom;
34  throw 0;
35  }
36 }
exprt & op1()
Definition: expr.h:106
exprt & op0()
Definition: expr.h:103
virtual void make_constant(exprt &expr)
virtual void implicit_typecast_bool(exprt &expr)
void convert(cpp_linkage_spect &)
void typecheck_expr(exprt &) override
const source_locationt & source_location() const
Definition: expr.h:234
bool is_false() const
Return whether the expression is a constant representing false.
Definition: expr.cpp:56
const irep_idt & id() const
Definition: irep.h:407
source_locationt source_location
Definition: message.h:247
mstreamt & error() const
Definition: message.h:399
static eomt eom
Definition: message.h:297
const irep_idt & get_value() const
C++ Language Type Checking.
Pre-defined types.
const string_constantt & to_string_constant(const exprt &expr)