-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expand documentation of is_compile_time_constantt
C11 Section 6.6 "Constant expressions" defines what are required to be constant expressions, and permits implementations to pick additional constant expressions.
- Loading branch information
1 parent
7d0523f
commit 8430887
Showing
1 changed file
with
8 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,8 +45,9 @@ Author: Daniel Kroening, [email protected] | |
#include <sstream> | ||
|
||
/// Architecturally similar to \ref can_forward_propagatet, but specialized for | ||
/// what is a constexpr, i.e., an expression that can be fully evaluated at | ||
/// compile time. | ||
/// what is an expression that can be fully evaluated at compile time within | ||
/// the limits of what the C standard permits. See 6.6 Constant expressions in | ||
/// C11. | ||
class is_compile_time_constantt | ||
{ | ||
public: | ||
|
@@ -67,16 +68,21 @@ class is_compile_time_constantt | |
/// "constants" | ||
bool is_constant(const exprt &e) const | ||
{ | ||
// non-standard numeric constant | ||
if(e.id() == ID_infinity) | ||
return true; | ||
|
||
// numeric, character, or pointer-typed constant | ||
if(e.is_constant()) | ||
return true; | ||
|
||
// possibly an address constant | ||
if(e.id() == ID_address_of) | ||
{ | ||
return is_constant_address_of(to_address_of_expr(e).object()); | ||
} | ||
// we choose to accept the following expressions (over constant operands) as | ||
// constant expressions | ||
else if( | ||
e.id() == ID_typecast || e.id() == ID_array_of || e.id() == ID_plus || | ||
e.id() == ID_mult || e.id() == ID_array || e.id() == ID_with || | ||
|