Skip to content
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

Implementation does not match declaration! Type missmatch on in-parameters! #186

Closed
blizzard4591 opened this issue Jun 2, 2017 · 3 comments

Comments

@blizzard4591
Copy link

blizzard4591 commented Jun 2, 2017

I am encountering this SyntaxErrorResult:

SyntaxErrorResult [Line: 12]: Incorrect Syntax
Implementation does not match declaration! Type missmatch on in-parameters! 1 arguments, 1 parameters, first missmatch at position 0, argument type { p_VOID : $Pointer$, p_FLOAT : $Pointer$, p_UINT : $Pointer$, p_UCHAR : $Pointer$, p_SINT : $Pointer$, p_SCHAR : $Pointer$ }, param type #in~PtrData : { p_VOID : $Pointer$, p_FLOAT : $Pointer$, p_UINT : $Pointer$, p_UCHAR : $Pointer$, p_SINT : $Pointer$, p_SCHAR : $Pointer$ }

on the following code:

typedef union _ptrUnion {
	volatile const void* p_VOID;
	const float* p_FLOAT;
	const unsigned short int* p_UINT;
	const unsigned char* p_UCHAR;
	const signed short int* p_SINT;
	const signed char* p_SCHAR;
} ptrUnion;

static void myFunc(ptrUnion PtrData);

static void myFunc(ptrUnion PtrData)
{  
  //
}

int main() {
	auto ptrUnion PtrData;
	PtrData.p_VOID = 0;

	myFunc(PtrData);
	
	return 0;
}

Am I missing something or is this a parser bug?
(Running v0.1.16)

@blizzard4591
Copy link
Author

The same happens with v0.1.17 fyi

@danieldietsch
Copy link
Member

At first glance this looks like a known bug of our C translation. Perhaps @alexandernutz knows how to fix it?

@Heizmann
Copy link
Member

Heizmann commented Jun 3, 2017

Problem is in lines before 312 in FunctionHandler, where we compare the parameters of function declaration and function definition (of myFunc).

  • It seems to me that the comparison is not needed but very helpful to point out bugs in our translation. (very good idea)
  • The comparison is done on the level of Boogie (reasonable)
  • The comparison is done by comparing the toString() representations of the parameter types (I don't like that)
  • The problem is triggered by a function declaration and function implementation that use different ASTType objects that have not the same locations (and location is part of toString()).

Solutions:

  1. Make sure that we have only one ASTType object per C type. (Maybe not doable in our architecture)
  2. Implement visitor for ASTTypes and VarLists that check if two ASTTypes are similar.
    Two ASTTypes are similar if all fields but "ILocation loc" and "IBoogieType boogieType" are similar (if applicable) or equivalent (according to equals()). Same definition of similar for VarLists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants