Skip to content

Commit 1d95ab4

Browse files
committed
Permit compound literals in place of PODs
1 parent e229b4c commit 1d95ab4

File tree

5 files changed

+16
-25
lines changed

5 files changed

+16
-25
lines changed

regression/cpp/List_initialization1/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.cpp
33
-std=c++11
44
^EXIT=0$

src/cpp/cpp_typecheck.h

-2
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,6 @@ class cpp_typecheckt:public c_typecheck_baset
483483
void typecheck_method_application(
484484
side_effect_expr_function_callt &expr);
485485

486-
void typecheck_assign(codet &code);
487-
488486
public:
489487
//
490488
// Type Conversions

src/cpp/cpp_typecheck_code.cpp

-22
Original file line numberDiff line numberDiff line change
@@ -449,25 +449,3 @@ void cpp_typecheckt::typecheck_block(codet &code)
449449

450450
c_typecheck_baset::typecheck_block(code);
451451
}
452-
453-
void cpp_typecheckt::typecheck_assign(codet &code)
454-
{
455-
if(code.operands().size()!=2)
456-
{
457-
error().source_location=code.find_source_location();
458-
error() << "assignment statement expected to have two operands"
459-
<< eom;
460-
throw 0;
461-
}
462-
463-
// turn into a side effect
464-
side_effect_exprt expr(code.get(ID_statement));
465-
expr.operands() = code.operands();
466-
typecheck_expr(expr);
467-
468-
code_expressiont code_expr;
469-
code_expr.expression()=expr;
470-
code_expr.add_source_location() = code.source_location();
471-
472-
code.swap(code_expr);
473-
}

src/cpp/cpp_typecheck_conversions.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,13 @@ void cpp_typecheckt::implicit_typecast(exprt &expr, const typet &type)
15081508
{
15091509
exprt e=expr;
15101510

1511+
if(
1512+
e.id() == ID_initializer_list && cpp_is_pod(type) &&
1513+
e.operands().size() == 1)
1514+
{
1515+
e = expr.op0();
1516+
}
1517+
15111518
if(!implicit_conversion_sequence(e, type, expr))
15121519
{
15131520
show_instantiation_stack(error());

src/cpp/cpp_typecheck_fargs.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@ bool cpp_typecheck_fargst::match(
129129
std::cout << "OK " << rank << '\n';
130130
#endif
131131
}
132+
else if(
133+
operand.id() == ID_initializer_list && cpp_typecheck.cpp_is_pod(type) &&
134+
operand.operands().size() == 1 &&
135+
cpp_typecheck.implicit_conversion_sequence(
136+
operand.op0(), type, new_expr, rank))
137+
{
138+
distance += rank;
139+
}
132140
else
133141
{
134142
#if 0

0 commit comments

Comments
 (0)