Skip to content

Commit eec7a5d

Browse files
author
thk123
committed
Turn the ID_C_typedef into a comment
This means that it will not be used to check types are equal, fixing the failing regression tests that were validating the types were equal (and they only differed by a typedef'd name).
1 parent c64eacc commit eec7a5d

File tree

3 files changed

+3
-42
lines changed

3 files changed

+3
-42
lines changed

src/ansi-c/c_typecheck_base.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,6 @@ class c_typecheck_baset:
262262
asm_label_mapt asm_label_map;
263263

264264
void apply_asm_label(const irep_idt &asm_label, symbolt &symbol);
265-
266-
private:
267-
static bool are_types_equal_ignoring_typedef(
268-
const typet type1, const typet &type2);
269265
};
270266

271267
#endif // CPROVER_ANSI_C_C_TYPECHECK_BASE_H

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ bool c_typecheck_baset::gcc_types_compatible_p(
140140
if(type1.id()==ID_c_enum)
141141
{
142142
if(type2.id()==ID_c_enum) // both are enums
143-
// We don't need to remove the typedef flag here since as it is an enum
144-
// we have already followed the enum tag to get to the underlying enum
145143
return type1==type2; // compares the tag
146144
else if(type2==type1.subtype())
147145
return true;
@@ -186,13 +184,12 @@ bool c_typecheck_baset::gcc_types_compatible_p(
186184
}
187185
else
188186
{
189-
if(are_types_equal_ignoring_typedef(type1, type2))
187+
if(type1==type2)
190188
{
191189
// Need to distinguish e.g. long int from int or
192190
// long long int from long int.
193191
// The rules appear to match those of C++.
194-
// Isn't this explictly handled by checking type1==type2 (since
195-
// operator== recursively checks all sub types).
192+
196193
if(type1.get(ID_C_c_type)==type2.get(ID_C_c_type))
197194
return true;
198195
}
@@ -203,38 +200,6 @@ bool c_typecheck_baset::gcc_types_compatible_p(
203200

204201
/*******************************************************************\
205202
206-
Function: c_typecheck_baset::are_types_equal_ignoring_typedef
207-
208-
Inputs:
209-
type1 - the first type to compare
210-
type2 - the second type to compare
211-
212-
Outputs: True if the types are equal
213-
214-
Purpose: To check whether two types are equal, ignoring if they have a
215-
different typedef tag. We do this by explictly removing the
216-
ID_C_typedef from the type before comparing. Then we just use
217-
operator== to compare the resultant types.
218-
219-
\*******************************************************************/
220-
bool c_typecheck_baset::are_types_equal_ignoring_typedef(
221-
const typet type1, const typet &type2)
222-
{
223-
typet non_typedefd_type1=type1;
224-
typet non_typedefd_type2=type2;
225-
if(type1.get(ID_C_typedef)!=ID_nil)
226-
{
227-
non_typedefd_type1.remove(ID_C_typedef);
228-
}
229-
if(type2.get(ID_C_typedef)!=ID_nil)
230-
{
231-
non_typedefd_type2.remove(ID_C_typedef);
232-
}
233-
return non_typedefd_type1==non_typedefd_type2;
234-
}
235-
236-
/*******************************************************************\
237-
238203
Function: c_typecheck_baset::typecheck_expr_main
239204
240205
Inputs:

src/util/irep_ids.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ concatenation
251251
infinity
252252
return_type
253253
typedef
254-
C_typedef
254+
C_typedef #typedef
255255
extern
256256
static
257257
auto

0 commit comments

Comments
 (0)