Skip to content

Commit

Permalink
Permit compound literals in place of PODs
Browse files Browse the repository at this point in the history
  • Loading branch information
tautschnig committed Jun 11, 2018
1 parent e229b4c commit 1d95ab4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion regression/cpp/List_initialization1/test.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG
CORE
main.cpp
-std=c++11
^EXIT=0$
Expand Down
2 changes: 0 additions & 2 deletions src/cpp/cpp_typecheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,6 @@ class cpp_typecheckt:public c_typecheck_baset
void typecheck_method_application(
side_effect_expr_function_callt &expr);

void typecheck_assign(codet &code);

public:
//
// Type Conversions
Expand Down
22 changes: 0 additions & 22 deletions src/cpp/cpp_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,25 +449,3 @@ void cpp_typecheckt::typecheck_block(codet &code)

c_typecheck_baset::typecheck_block(code);
}

void cpp_typecheckt::typecheck_assign(codet &code)
{
if(code.operands().size()!=2)
{
error().source_location=code.find_source_location();
error() << "assignment statement expected to have two operands"
<< eom;
throw 0;
}

// turn into a side effect
side_effect_exprt expr(code.get(ID_statement));
expr.operands() = code.operands();
typecheck_expr(expr);

code_expressiont code_expr;
code_expr.expression()=expr;
code_expr.add_source_location() = code.source_location();

code.swap(code_expr);
}
7 changes: 7 additions & 0 deletions src/cpp/cpp_typecheck_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1508,6 +1508,13 @@ void cpp_typecheckt::implicit_typecast(exprt &expr, const typet &type)
{
exprt e=expr;

if(
e.id() == ID_initializer_list && cpp_is_pod(type) &&
e.operands().size() == 1)
{
e = expr.op0();
}

if(!implicit_conversion_sequence(e, type, expr))
{
show_instantiation_stack(error());
Expand Down
8 changes: 8 additions & 0 deletions src/cpp/cpp_typecheck_fargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ bool cpp_typecheck_fargst::match(
std::cout << "OK " << rank << '\n';
#endif
}
else if(
operand.id() == ID_initializer_list && cpp_typecheck.cpp_is_pod(type) &&
operand.operands().size() == 1 &&
cpp_typecheck.implicit_conversion_sequence(
operand.op0(), type, new_expr, rank))
{
distance += rank;
}
else
{
#if 0
Expand Down

0 comments on commit 1d95ab4

Please sign in to comment.