Skip to content

Commit 1d65f09

Browse files
tautschnigandreast271
authored andcommitted
Do not lose method qualifiers
1 parent 33340ea commit 1d65f09

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

regression/cpp/Template_Specialisation2/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.ii
33

44
^EXIT=0$

src/cpp/cpp_typecheck_type.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ void cpp_typecheckt::typecheck_type(typet &type)
7979
}
8080
else if(type.id()==ID_pointer)
8181
{
82+
c_qualifierst qualifiers(type);
83+
8284
// the pointer might have a qualifier, but do subtype first
8385
typecheck_type(type.subtype());
8486

@@ -117,6 +119,11 @@ void cpp_typecheckt::typecheck_type(typet &type)
117119
}
118120
}
119121
}
122+
123+
if(type.get_bool(ID_C_constant))
124+
qualifiers.is_constant = true;
125+
126+
qualifiers.write(type);
120127
}
121128
else if(type.id()==ID_array)
122129
{

src/cpp/parse.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5410,7 +5410,13 @@ bool Parser::rTypeName(typet &tname)
54105410
if(!rDeclarator(declarator, kCastDeclarator, false, false))
54115411
return false;
54125412

5413-
tname.swap(declarator.type());
5413+
if(!declarator.method_qualifier().id().empty())
5414+
{
5415+
tname.swap(declarator.method_qualifier());
5416+
merge_types(declarator.type(), tname);
5417+
}
5418+
else
5419+
tname.swap(declarator.type());
54145420

54155421
// make type_name subtype of arg
54165422
make_subtype(type_name, tname);

0 commit comments

Comments
 (0)