Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] CODAN question for function can not be resolved AND invalid arguments!

My point is: It is VALID in C to have mismatch (yes without the
declaration) and it would even RUN. So indexer CAN link functions even
arguments are mismatching - it is not a binding problem in C. It is a
type checking problem.
If you trying to convince me that parser should produce an error here
- I don't think you can.
CDT Parser/Binder does NOT do  a LOT of semantic checks  because it is
not its job. It was not designed to
replace the C/C++ code generator - which would give you all semantic
errors. However seeing semantic errors as you
type (like in java) is nice, so we have Codan which can do it. If user
don't not want these checks he can turn them off.
As Sergey said, parser should be efficient and not spent time on this.


2010/9/10 Tomasz Wesołowski <kosashi@xxxxxxxxx>:
>
>
> 2010/9/10 Alena Laskavaia <elaskavaia.cdt@xxxxxxxxx>
>>
>> If you really think it is invalid create this program: two files (No
>> headers).
>>
>> foo.c:
>>    foo(int a) {
>>   }
>>
>> main.c:
>>   main(){
>>      foo("bla");
>>   }
>
>
> In this case, in translation unit main.c, function 'foo' is undefined. Thus
> it's assumed it's int foo() (abitrary number of params), so it will compile
> and link. The same if you change call to foo("bla","bla").
> Change main.c to:
>
> int foo(int);
> main() {
>    foo("bla","bla");
> }
>
> and it won't compile because of parameter mismatch - this is the case we're
> discussing. C++ parser gives a problem binding here, C parser doesn't =
> inconsistency.
>


Back to the top