Skip to content

Commit 118f41f

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2352 from tautschnig/c++-auto-tc
C++ front-end: fix auto+references after already-typechecked cleanup
2 parents 5a4dc8d + 72156d5 commit 118f41f

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/cpp/cpp_typecheck_compound_type.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ bool cpp_typecheckt::has_auto(const typet &type)
6161
{
6262
if(type.id() == ID_auto)
6363
return true;
64-
else if(type.id() == ID_merged_type || type.id() == ID_frontend_pointer)
64+
else if(
65+
type.id() == ID_merged_type || type.id() == ID_frontend_pointer ||
66+
type.id() == ID_pointer)
6567
{
6668
forall_subtypes(it, type)
6769
if(has_auto(*it))

src/cpp/cpp_typecheck_initializer.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ void cpp_typecheckt::convert_initializer(symbolt &symbol)
6363
if(is_reference(symbol.type))
6464
{
6565
typecheck_expr(symbol.value);
66+
67+
if(has_auto(symbol.type))
68+
{
69+
cpp_convert_auto(symbol.type, symbol.value.type());
70+
typecheck_type(symbol.type);
71+
implicit_typecast(symbol.value, symbol.type);
72+
}
73+
6674
reference_initializer(symbol.value, symbol.type);
6775
}
6876
else if(cpp_is_pod(symbol.type))

0 commit comments

Comments
 (0)