Skip to content

Commit 9ec1366

Browse files
committed
Failing regression test from diffblue#933
1 parent dd29682 commit 9ec1366

8 files changed

+72
-14
lines changed

regression/cbmc/cpp2/main.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <cassert>
2+
#include <stdint.h>
3+
#include <stdbool.h>
4+
5+
#undef HOTFIX
6+
7+
typedef struct {
8+
uint32_t value_31_0 : 32;
9+
} signal32_t;
10+
11+
typedef struct {
12+
uint8_t value_0_0 : 1;
13+
} signal1_t;
14+
15+
static inline bool yosys_simplec_get_bit_25_of_32(const signal32_t *sig)
16+
{
17+
return (sig->value_31_0 >> 25) & 1;
18+
}
19+
20+
struct rvfi_insn_srai_state_t
21+
{
22+
signal32_t rvfi_insn;
23+
signal32_t rvfi_rs1_rdata;
24+
signal1_t _abc_1398_n364;
25+
signal1_t _abc_1398_n363;
26+
};
27+
28+
void test(rvfi_insn_srai_state_t state, bool valid)
29+
{
30+
#ifndef HOTFIX
31+
state._abc_1398_n364.value_0_0 = yosys_simplec_get_bit_25_of_32(&state.rvfi_insn) ?
32+
yosys_simplec_get_bit_25_of_32(&state.rvfi_rs1_rdata) : state._abc_1398_n363.value_0_0;
33+
#else
34+
state._abc_1398_n364.value_0_0 = yosys_simplec_get_bit_25_of_32(&state.rvfi_insn) ?
35+
yosys_simplec_get_bit_25_of_32(&state.rvfi_rs1_rdata) : (bool)state._abc_1398_n363.value_0_0;
36+
#endif
37+
38+
assert(valid);
39+
}
40+
41+
int main(int argc, char* argv[])
42+
{
43+
rvfi_insn_srai_state_t state;
44+
bool valid;
45+
test(state, valid);
46+
return 0;
47+
}

regression/cbmc/cpp2/test.desc

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
KNOWNBUG
2+
main.cpp
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
9+
^equality without matching types
10+
--
11+
This has been reported as #933.

src/cpp/cpp_declarator_converter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ symbolt &cpp_declarator_convertert::convert(
6868
scope=&cpp_typecheck.cpp_scopes.current_scope();
6969

7070
// check the declarator-part of the type, in that scope
71-
//TODO: if it is a friend declaration we have to type-check it
71+
// TODO: if it is a friend declaration we have to type-check it
7272
// in our current scope to have access to the correct
7373
// template parameters, although the symbol finally resides
7474
// in the resolved scope (actually it should be sufficient
@@ -77,7 +77,7 @@ symbolt &cpp_declarator_convertert::convert(
7777
if(!is_friend)
7878
cpp_typecheck.typecheck_type(final_type);
7979
}
80-
//TODO: see comment above
80+
// TODO: see comment above
8181
if(is_friend)
8282
cpp_typecheck.typecheck_type(final_type);
8383

src/cpp/cpp_instantiate_template.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ const symbolt &cpp_typecheckt::instantiate_template(
458458
const irep_idt& new_symb_id = new_decl.type().get(ID_identifier);
459459
symbolt &new_symb = symbol_table.get_writeable_ref(new_symb_id);
460460

461-
//add template arguments to type in order to retrieve template map
462-
// when typechecking function body
461+
// add template arguments to type in order to retrieve template map
462+
// when typechecking function body
463463
new_symb.type.set(ID_C_template, template_type);
464464
new_symb.type.set(ID_C_template_arguments, specialization_template_args);
465465

src/cpp/cpp_typecheck_compound_type.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ void cpp_typecheckt::typecheck_friend_declaration(
894894
{
895895
#ifdef DEBUG
896896
std::cout << "decl: " << sub_it->pretty() << "\n with value "
897-
<< sub_it->value().pretty() << '\n';
897+
<< sub_it->value().pretty() << '\n';
898898
std::cout << " scope: " << cpp_scopes.current_scope().prefix << '\n';
899899
#endif
900900
// In which scope are we going to typecheck this?

src/cpp/cpp_typecheck_expr.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ bool cpp_typecheckt::overloadable(const exprt &expr)
433433
t=t.subtype();
434434

435435
if(t.id()==ID_struct ||
436-
//this might be an incomplete struct (template) here
436+
// this might be an incomplete struct (template) here
437437
t.id()==ID_incomplete_struct ||
438438
t.id()==ID_union ||
439439
t.id()==ID_c_enum)
@@ -605,7 +605,7 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
605605
// We try and fail silently, maybe conversions will work
606606
// instead.
607607

608-
//TODO: need to resolve an incomplete struct (template) here
608+
// TODO: need to resolve an incomplete struct (template) here
609609
// go into scope of first operand
610610
if(expr.op0().type().id()==ID_symbol &&
611611
follow(expr.op0().type()).id()==ID_struct)
@@ -2394,8 +2394,9 @@ void cpp_typecheckt::typecheck_method_application(
23942394
cpp_saved_template_mapt saved_map(template_map);
23952395
const irept &template_type=tag_symbol.type.find(ID_C_template);
23962396
const irept &template_args=tag_symbol.type.find(ID_C_template_arguments);
2397-
template_map.build(static_cast<const template_typet &>(template_type),
2398-
static_cast<const cpp_template_args_tct &>(template_args));
2397+
template_map.build(
2398+
static_cast<const template_typet &>(template_type),
2399+
static_cast<const cpp_template_args_tct &>(template_args));
23992400
add_method_body(&method_symbol);
24002401
#ifdef DEBUG
24012402
std::cout << "MAP for " << symbol << ":" << std::endl;

src/cpp/cpp_typecheck_method_bodies.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void cpp_typecheckt::add_method_body(symbolt *_method_symbol)
7070
return;
7171
}
7272
method_bodies.push_back(method_bodyt(
73-
_method_symbol, template_map, instantiation_stack));
73+
_method_symbol, template_map, instantiation_stack));
7474

7575
// Converting a method body might add method bodies for methods
7676
// that we have already analyzed. Hence, we have to keep track.

src/cpp/cpp_typecheck_resolve.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ Author: Daniel Kroening, [email protected]
2828
#include <ansi-c/anonymous_member.h>
2929

3030
#include "cpp_typecheck.h"
31-
#include "cpp_typecheck_resolve.h"
3231
#include "cpp_template_type.h"
3332
#include "cpp_type2name.h"
3433
#include "cpp_util.h"
@@ -683,9 +682,9 @@ void cpp_typecheck_resolvet::resolve_argument(
683682
exprt &argument,
684683
const cpp_typecheck_fargst &fargs)
685684
{
686-
if(argument.id()=="ambiguous") //could come from a template parameter
685+
if(argument.id()=="ambiguous") // could come from a template parameter
687686
{
688-
//this must be resolved in the template scope
687+
// this must be resolved in the template scope
689688
cpp_save_scopet save_scope(cpp_typecheck.cpp_scopes);
690689
cpp_typecheck.cpp_scopes.go_to(*original_scope);
691690

@@ -934,7 +933,7 @@ cpp_scopet &cpp_typecheck_resolvet::resolve_scope(
934933
#ifdef DEBUG
935934
std::cout << "S: "
936935
<< cpp_typecheck.cpp_scopes.current_scope().identifier
937-
<< std::endl;
936+
<< "\n";
938937
cpp_typecheck.cpp_scopes.current_scope().print(std::cout);
939938
std::cout << "X: " << id_set.size() <<std::endl;
940939
#endif

0 commit comments

Comments
 (0)