-
Notifications
You must be signed in to change notification settings - Fork 275
Fix pointer type #1390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Fix pointer type #1390
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1492,19 +1492,22 @@ void c_typecheck_baset::adjust_function_parameter(typet &type) const | |
{ | ||
if(type.id()==ID_array) | ||
{ | ||
source_locationt source_location=type.source_location(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be const. |
||
type=pointer_type(type.subtype()); | ||
type.remove(ID_size); | ||
type.remove(ID_C_constant); | ||
type.add_source_location()=source_location; | ||
} | ||
else if(type.id()==ID_code) | ||
{ | ||
// see ISO/IEC 9899:1999 page 199 clause 8, | ||
// may be hidden in typedef | ||
source_locationt source_location=type.source_location(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be const. |
||
type=pointer_type(type); | ||
type.add_source_location()=source_location; | ||
} | ||
else if(type.id()==ID_KnR) | ||
{ | ||
// any KnR args without type yet? | ||
type=signed_int_type(); // the default is integer! | ||
// no source location | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,6 @@ Author: Daniel Kroening, [email protected] | |
|
||
#include <util/type.h> | ||
|
||
void cpp_convert_plain_type(typet &type); | ||
void cpp_convert_plain_type(typet &); | ||
|
||
#endif // CPROVER_CPP_CPP_CONVERT_TYPE_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,9 @@ Author: Daniel Kroening, [email protected] | |
#include <util/std_code.h> | ||
#include <util/std_expr.h> | ||
#include <util/std_types.h> | ||
#include <util/c_types.h> | ||
|
||
#include <ansi-c/ansi_c_y.tab.h> | ||
#include <util/c_types.h> | ||
|
||
#include "cpp_token_buffer.h" | ||
#include "cpp_member_spec.h" | ||
|
@@ -3016,7 +3016,7 @@ bool Parser::optPtrOperator(typet &ptrs) | |
|
||
if(t=='*') | ||
{ | ||
typet op=pointer_type(typet(ID_nil)); | ||
typet op(ID_frontend_pointer); // width gets set during conversion | ||
cpp_tokent tk; | ||
lex.get_token(tk); | ||
set_location(op, tk); | ||
|
@@ -3079,7 +3079,7 @@ bool Parser::optPtrOperator(typet &ptrs) | |
{ | ||
cpp_tokent tk; | ||
lex.get_token(tk); | ||
typet op=pointer_type(typet(ID_nil)); | ||
typet op(ID_frontend_pointer); // width gets set during conversion | ||
op.set(ID_C_reference, true); | ||
set_location(op, tk); | ||
t_list.push_front(op); | ||
|
@@ -3088,7 +3088,7 @@ bool Parser::optPtrOperator(typet &ptrs) | |
{ | ||
cpp_tokent tk; | ||
lex.get_token(tk); | ||
typet op=pointer_type(typet(ID_nil)); | ||
typet op(ID_frontend_pointer); // width gets set during conversion | ||
op.set(ID_C_rvalue_reference, true); | ||
set_location(op, tk); | ||
t_list.push_front(op); | ||
|
@@ -3531,7 +3531,7 @@ bool Parser::rPtrToMember(irept &ptr_to_mem) | |
std::cout << std::string(__indent, ' ') << "Parser::rPtrToMember 0\n"; | ||
#endif | ||
|
||
typet ptm=pointer_type(typet(ID_nil)); | ||
typet ptm(ID_frontend_pointer); // width gets set during conversion | ||
irept &name = ptm.add("to-member"); | ||
name=cpp_namet(); | ||
irept::subt &components=name.get_sub(); | ||
|
@@ -6478,6 +6478,7 @@ bool Parser::rPrimaryExpr(exprt &exp) | |
|
||
case TOK_NULLPTR: | ||
lex.get_token(tk); | ||
// as an exception, we set the width of pointer | ||
exp=constant_exprt(ID_NULL, pointer_type(typet(ID_nullptr))); | ||
set_location(exp, tk); | ||
#ifdef DEBUG | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should use the proper pointer_type constructor