From 934c5552333ebdbe6d746a72b10c66f69d42ca24 Mon Sep 17 00:00:00 2001 From: Michael Tautschnig Date: Mon, 21 Aug 2017 09:13:16 +0100 Subject: [PATCH] Do not lose method qualifiers --- regression/cpp/Template_Specialisation2/test.desc | 2 +- src/cpp/cpp_typecheck_type.cpp | 7 +++++++ src/cpp/parse.cpp | 8 +++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/regression/cpp/Template_Specialisation2/test.desc b/regression/cpp/Template_Specialisation2/test.desc index 39954b104f7..0428cb127bc 100644 --- a/regression/cpp/Template_Specialisation2/test.desc +++ b/regression/cpp/Template_Specialisation2/test.desc @@ -1,4 +1,4 @@ -KNOWNBUG +CORE main.ii ^EXIT=0$ diff --git a/src/cpp/cpp_typecheck_type.cpp b/src/cpp/cpp_typecheck_type.cpp index 1c2ba93ec14..4f0f5f66708 100644 --- a/src/cpp/cpp_typecheck_type.cpp +++ b/src/cpp/cpp_typecheck_type.cpp @@ -78,6 +78,8 @@ void cpp_typecheckt::typecheck_type(typet &type) } else if(type.id()==ID_pointer) { + c_qualifierst qualifiers(type); + // the pointer/reference might have a qualifier, // but do subtype first typecheck_type(type.subtype()); @@ -114,6 +116,11 @@ void cpp_typecheckt::typecheck_type(typet &type) } } } + + if(type.get_bool(ID_C_constant)) + qualifiers.is_constant = true; + + qualifiers.write(type); } else if(type.id()==ID_array) { diff --git a/src/cpp/parse.cpp b/src/cpp/parse.cpp index e4ed361160a..4fc00affe96 100644 --- a/src/cpp/parse.cpp +++ b/src/cpp/parse.cpp @@ -5222,7 +5222,13 @@ bool Parser::rTypeName(typet &tname) if(!rDeclarator(declarator, kCastDeclarator, false, false)) return false; - tname.swap(declarator.type()); + if(!declarator.method_qualifier().id().empty()) + { + tname.swap(declarator.method_qualifier()); + merge_types(declarator.type(), tname); + } + else + tname.swap(declarator.type()); // make type_name subtype of arg make_subtype(type_name, tname);