mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
[CPP-340] Add more test case; exclude K&R definitions of functions when looking
up ()-declarations; refactor QL code.
This commit is contained in:
@@ -14,23 +14,26 @@
|
||||
|
||||
import cpp
|
||||
|
||||
predicate arithTypesMatch(Type arg, Type parm) {
|
||||
arg instanceof ArithmeticType and
|
||||
parm instanceof ArithmeticType and
|
||||
arg.getSize() = parm.getSize() and
|
||||
(
|
||||
arg instanceof IntegralOrEnumType and
|
||||
parm instanceof IntegralOrEnumType
|
||||
or
|
||||
arg instanceof FloatingPointType and
|
||||
parm instanceof FloatingPointType
|
||||
)
|
||||
}
|
||||
pragma[inline]
|
||||
predicate pointerArgTypeMayBeUsed(Type arg, Type parm) {
|
||||
arg = parm
|
||||
or
|
||||
// arithmetic types
|
||||
arg instanceof ArithmeticType and
|
||||
parm instanceof ArithmeticType and
|
||||
arg.getSize() = parm.getSize() and
|
||||
(
|
||||
arg instanceof IntegralType and
|
||||
parm instanceof IntegralType
|
||||
or
|
||||
arg instanceof FloatingPointType and
|
||||
parm instanceof FloatingPointType
|
||||
)
|
||||
arithTypesMatch(arg, parm)
|
||||
or
|
||||
// pointers to void are ok
|
||||
// conversion to/from pointers to void is allowed
|
||||
arg instanceof VoidType
|
||||
or
|
||||
parm instanceof VoidType
|
||||
@@ -40,23 +43,22 @@ pragma[inline]
|
||||
predicate argTypeMayBeUsed(Type arg, Type parm) {
|
||||
arg = parm
|
||||
or
|
||||
// float arguments will have been promoted to double,
|
||||
// and the parameter must match this
|
||||
arg instanceof DoubleType and
|
||||
parm instanceof DoubleType
|
||||
or
|
||||
// integral arguments are promoted to int (but not long long).
|
||||
arg instanceof IntegralType and
|
||||
arg.getSize() = 4 and
|
||||
parm instanceof IntegralType and
|
||||
parm.getSize() = 4
|
||||
// arithmetic types
|
||||
arithTypesMatch(arg, parm)
|
||||
or
|
||||
// pointers to compatible types
|
||||
pointerArgTypeMayBeUsed(arg.(PointerType).getBaseType().getUnspecifiedType(),
|
||||
parm.(PointerType).getBaseType().getUnspecifiedType())
|
||||
or
|
||||
pointerArgTypeMayBeUsed(arg.(ArrayType).getBaseType().getUnspecifiedType(),
|
||||
parm.(PointerType).getBaseType().getUnspecifiedType())
|
||||
or
|
||||
// C11 arrays
|
||||
pointerArgTypeMayBeUsed(arg.(PointerType).getBaseType().getUnspecifiedType(),
|
||||
parm.(ArrayType).getBaseType().getUnspecifiedType())
|
||||
or
|
||||
pointerArgTypeMayBeUsed(arg.(ArrayType).getBaseType().getUnspecifiedType(),
|
||||
parm.(ArrayType).getBaseType().getUnspecifiedType())
|
||||
}
|
||||
|
||||
// This predicate doesn't necessarily have to exist, but if it does exist
|
||||
@@ -69,11 +71,17 @@ predicate argMayBeUsed(Expr arg, Parameter parm) {
|
||||
parm.getType().getUnspecifiedType())
|
||||
}
|
||||
|
||||
// True if function was ()-declared, but not (void)-declared
|
||||
pragma[inline]
|
||||
// True if function was ()-declared, but not (void)-declared or K&R-defined
|
||||
predicate hasZeroParamDecl(Function f) {
|
||||
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
||||
not fde.hasVoidParamList() and fde.getNumberOfParameters() = 0
|
||||
not fde.hasVoidParamList() and fde.getNumberOfParameters() = 0 and not fde.isDefinition()
|
||||
)
|
||||
}
|
||||
|
||||
// True if this file (or header) was compiled as a C file
|
||||
predicate isCompiledAsC(Function f) {
|
||||
exists(File file | file.compiledAsC() |
|
||||
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -81,12 +89,14 @@ from FunctionCall fc, Function f, Parameter p
|
||||
where
|
||||
f = fc.getTarget() and
|
||||
p = f.getAParameter() and
|
||||
not f.isVarargs() and
|
||||
p.getIndex() < fc.getNumberOfArguments() and
|
||||
hasZeroParamDecl(f) and
|
||||
isCompiledAsC(f) and
|
||||
not f.isVarargs() and
|
||||
not f instanceof BuiltInFunction and
|
||||
p.getIndex() < fc.getNumberOfArguments() and
|
||||
// Parameter p and its corresponding call argument must have mismatched types
|
||||
not argMayBeUsed(fc.getArgument(p.getIndex()), p)
|
||||
select fc, "Calling $@: argument $@ of type $@ is incompatible with parameter $@", f, f.toString(),
|
||||
select fc, "Calling $@: argument $@ of type $@ is incompatible with parameter $@.", f, f.toString(),
|
||||
fc.getArgument(p.getIndex()) as arg, arg.toString(),
|
||||
arg.getFullyConverted().getType().getUnspecifiedType() as atype,
|
||||
atype.toString(), p, p.getTypedName()
|
||||
arg.getExplicitlyConverted().getType().getUnspecifiedType() as atype, atype.toString(), p,
|
||||
p.getTypedName()
|
||||
|
||||
@@ -15,17 +15,30 @@
|
||||
|
||||
import cpp
|
||||
|
||||
// True if function was ()-declared, but not (void)-declared or K&R-defined
|
||||
predicate hasZeroParamDecl(Function f) {
|
||||
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
||||
not fde.hasVoidParamList() and fde.getNumberOfParameters() = 0 and not fde.isDefinition()
|
||||
)
|
||||
}
|
||||
|
||||
// True if this file (or header) was compiled as a C file
|
||||
predicate isCompiledAsC(Function f) {
|
||||
exists(File file | file.compiledAsC() |
|
||||
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
|
||||
)
|
||||
}
|
||||
|
||||
from FunctionCall fc, Function f
|
||||
where
|
||||
f = fc.getTarget() and
|
||||
not f.isVarargs() and
|
||||
// There must be a zero-parameter declaration (explicit or implicit)
|
||||
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
||||
fde.getNumberOfParameters() = 0
|
||||
) and
|
||||
not f instanceof BuiltInFunction and
|
||||
hasZeroParamDecl(f) and
|
||||
isCompiledAsC(f) and
|
||||
// There is an explicit declaration of the function whose parameter count is larger
|
||||
// than the number of call arguments
|
||||
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
||||
not fde.isImplicit() and fde.getNumberOfParameters() > fc.getNumberOfArguments()
|
||||
fde.getNumberOfParameters() > fc.getNumberOfArguments()
|
||||
)
|
||||
select fc, "This call has fewer arguments than required by $@.", f, f.toString()
|
||||
|
||||
@@ -13,14 +13,27 @@
|
||||
|
||||
import cpp
|
||||
|
||||
// True if function was ()-declared, but not (void)-declared or K&R-defined
|
||||
predicate hasZeroParamDecl(Function f) {
|
||||
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
||||
not fde.hasVoidParamList() and fde.getNumberOfParameters() = 0 and not fde.isDefinition()
|
||||
)
|
||||
}
|
||||
|
||||
// True if this file (or header) was compiled as a C file
|
||||
predicate isCompiledAsC(Function f) {
|
||||
exists(File file | file.compiledAsC() |
|
||||
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
|
||||
)
|
||||
}
|
||||
|
||||
from FunctionCall fc, Function f
|
||||
where
|
||||
f = fc.getTarget() and
|
||||
not f.isVarargs() and
|
||||
// There must be a zero-parameter declaration (explicit or implicit)
|
||||
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
||||
fde.getNumberOfParameters() = 0
|
||||
) and
|
||||
not f instanceof BuiltInFunction and
|
||||
hasZeroParamDecl(f) and
|
||||
isCompiledAsC(f) and
|
||||
// There must not exist a declaration with the number of parameters
|
||||
// at least as large as the number of call arguments
|
||||
not exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
| test.c:25:3:25:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:24:3:24:3 | not_yet_declared2 | not_yet_declared2 | test.c:25:21:25:22 | ca | ca | file://:0:0:0:0 | int * | int * | test.c:54:24:54:26 | p#0 | int p#0 |
|
||||
| test.c:25:3:25:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:54:6:54:22 | not_yet_declared2 | not_yet_declared2 | test.c:25:21:25:22 | ca | ca | file://:0:0:0:0 | int * | int * | test.c:54:24:54:26 | p#0 | int p#0 |
|
||||
| test.c:32:3:32:29 | call to declared_empty_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:55:6:55:32 | declared_empty_defined_with | declared_empty_defined_with | test.c:32:31:32:32 | & ... | & ... | file://:0:0:0:0 | int * | int * | test.c:55:38:55:38 | x | int x |
|
||||
| test.c:36:3:36:27 | call to not_declared_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:58:6:58:30 | not_declared_defined_with | not_declared_defined_with | test.c:36:29:36:31 | 4 | 4 | file://:0:0:0:0 | long long | long long | test.c:58:36:58:36 | x | int x |
|
||||
| test.c:36:3:36:27 | call to not_declared_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:58:6:58:30 | not_declared_defined_with | not_declared_defined_with | test.c:36:37:36:42 | 2500000000.0 | 2500000000.0 | file://:0:0:0:0 | double | double | test.c:58:50:58:50 | z | int z |
|
||||
| test.c:39:3:39:24 | call to declared_with_pointers | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:5:6:5:27 | declared_with_pointers | declared_with_pointers | test.c:39:26:39:31 | 3500000000000000.0 | 3500000000000000.0 | file://:0:0:0:0 | double | double | test.c:70:34:70:34 | x | int * x |
|
||||
| test.c:39:3:39:24 | call to declared_with_pointers | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:5:6:5:27 | declared_with_pointers | declared_with_pointers | test.c:39:34:39:34 | 0 | 0 | file://:0:0:0:0 | int | int | test.c:70:43:70:43 | y | void * y |
|
||||
| test.c:39:3:39:24 | call to declared_with_pointers | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:70:6:70:27 | declared_with_pointers | declared_with_pointers | test.c:39:26:39:31 | 3500000000000000.0 | 3500000000000000.0 | file://:0:0:0:0 | double | double | test.c:70:34:70:34 | x | int * x |
|
||||
| test.c:39:3:39:24 | call to declared_with_pointers | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:70:6:70:27 | declared_with_pointers | declared_with_pointers | test.c:39:34:39:34 | 0 | 0 | file://:0:0:0:0 | int | int | test.c:70:43:70:43 | y | void * y |
|
||||
| test.c:41:3:41:21 | call to declared_with_array | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:6:6:6:24 | declared_with_array | declared_with_array | test.c:41:23:41:24 | & ... | & ... | file://:0:0:0:0 | int * | int * | test.c:71:31:71:31 | a | char[6] a |
|
||||
| test.c:41:3:41:21 | call to declared_with_array | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:71:6:71:24 | declared_with_array | declared_with_array | test.c:41:23:41:24 | & ... | & ... | file://:0:0:0:0 | int * | int * | test.c:71:31:71:31 | a | char[6] a |
|
||||
| test.c:43:3:43:20 | call to defined_with_float | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:73:7:73:24 | defined_with_float | defined_with_float | test.c:43:22:43:24 | 2.0 | 2.0 | file://:0:0:0:0 | double | double | test.c:73:32:73:32 | f | float f |
|
||||
| test.c:44:3:44:20 | call to defined_with_float | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:73:7:73:24 | defined_with_float | defined_with_float | test.c:44:22:44:24 | 2.0 | 2.0 | file://:0:0:0:0 | double | double | test.c:73:32:73:32 | f | float f |
|
||||
| test.c:47:3:47:21 | call to defined_with_double | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:77:8:77:26 | defined_with_double | defined_with_double | test.c:47:23:47:25 | 99 | 99 | file://:0:0:0:0 | int | int | test.c:77:35:77:35 | d | double d |
|
||||
| test.c:49:3:49:24 | call to defined_with_long_long | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:81:11:81:32 | defined_with_long_long | defined_with_long_long | test.c:49:26:49:28 | 99 | 99 | file://:0:0:0:0 | int | int | test.c:81:44:81:45 | ll | long long ll |
|
||||
| test.c:50:3:50:24 | call to defined_with_long_long | Calling $@: argument $@ of type $@ is incompatible with parameter $@ | test.c:81:11:81:32 | defined_with_long_long | defined_with_long_long | test.c:50:26:50:26 | 3 | 3 | file://:0:0:0:0 | int | int | test.c:81:44:81:45 | ll | long long ll |
|
||||
| test.c:32:3:32:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:31:3:31:3 | not_yet_declared2 | not_yet_declared2 | test.c:32:21:32:22 | ca | ca | file://:0:0:0:0 | int * | int * | test.c:66:24:66:26 | p#0 | int p#0 |
|
||||
| test.c:32:3:32:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:31:3:31:3 | not_yet_declared2 | not_yet_declared2 | test.c:32:21:32:22 | ca | ca | file://:0:0:0:0 | int[4] | int[4] | test.c:66:24:66:26 | p#0 | int p#0 |
|
||||
| test.c:32:3:32:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:66:6:66:22 | not_yet_declared2 | not_yet_declared2 | test.c:32:21:32:22 | ca | ca | file://:0:0:0:0 | int * | int * | test.c:66:24:66:26 | p#0 | int p#0 |
|
||||
| test.c:32:3:32:19 | call to not_yet_declared2 | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:66:6:66:22 | not_yet_declared2 | not_yet_declared2 | test.c:32:21:32:22 | ca | ca | file://:0:0:0:0 | int[4] | int[4] | test.c:66:24:66:26 | p#0 | int p#0 |
|
||||
| test.c:39:3:39:29 | call to declared_empty_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:67:6:67:32 | declared_empty_defined_with | declared_empty_defined_with | test.c:39:31:39:32 | & ... | & ... | file://:0:0:0:0 | int * | int * | test.c:67:38:67:38 | x | int x |
|
||||
| test.c:43:3:43:27 | call to not_declared_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:70:6:70:30 | not_declared_defined_with | not_declared_defined_with | test.c:43:29:43:31 | 4 | 4 | file://:0:0:0:0 | long long | long long | test.c:70:36:70:36 | x | int x |
|
||||
| test.c:43:3:43:27 | call to not_declared_defined_with | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:70:6:70:30 | not_declared_defined_with | not_declared_defined_with | test.c:43:37:43:42 | 2500000000.0 | 2500000000.0 | file://:0:0:0:0 | float | float | test.c:70:50:70:50 | z | int z |
|
||||
| test.c:46:3:46:24 | call to declared_with_pointers | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:5:6:5:27 | declared_with_pointers | declared_with_pointers | test.c:46:26:46:31 | 3500000000000000.0 | 3500000000000000.0 | file://:0:0:0:0 | double | double | test.c:82:34:82:34 | x | int * x |
|
||||
| test.c:46:3:46:24 | call to declared_with_pointers | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:5:6:5:27 | declared_with_pointers | declared_with_pointers | test.c:46:34:46:34 | 0 | 0 | file://:0:0:0:0 | int | int | test.c:82:43:82:43 | y | void * y |
|
||||
| test.c:46:3:46:24 | call to declared_with_pointers | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:82:6:82:27 | declared_with_pointers | declared_with_pointers | test.c:46:26:46:31 | 3500000000000000.0 | 3500000000000000.0 | file://:0:0:0:0 | double | double | test.c:82:34:82:34 | x | int * x |
|
||||
| test.c:46:3:46:24 | call to declared_with_pointers | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:82:6:82:27 | declared_with_pointers | declared_with_pointers | test.c:46:34:46:34 | 0 | 0 | file://:0:0:0:0 | int | int | test.c:82:43:82:43 | y | void * y |
|
||||
| test.c:48:3:48:21 | call to declared_with_array | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:6:6:6:24 | declared_with_array | declared_with_array | test.c:48:23:48:24 | & ... | & ... | file://:0:0:0:0 | int * | int * | test.c:83:31:83:31 | a | char[6] a |
|
||||
| test.c:48:3:48:21 | call to declared_with_array | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:83:6:83:24 | declared_with_array | declared_with_array | test.c:48:23:48:24 | & ... | & ... | file://:0:0:0:0 | int * | int * | test.c:83:31:83:31 | a | char[6] a |
|
||||
| test.c:50:3:50:20 | call to defined_with_float | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:85:7:85:24 | defined_with_float | defined_with_float | test.c:50:22:50:24 | 2.0 | 2.0 | file://:0:0:0:0 | float | float | test.c:85:32:85:32 | f | float f |
|
||||
| test.c:51:3:51:20 | call to defined_with_float | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:85:7:85:24 | defined_with_float | defined_with_float | test.c:51:22:51:24 | 2.0 | 2.0 | file://:0:0:0:0 | double | double | test.c:85:32:85:32 | f | float f |
|
||||
| test.c:54:3:54:21 | call to defined_with_double | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:89:8:89:26 | defined_with_double | defined_with_double | test.c:54:23:54:25 | 99 | 99 | file://:0:0:0:0 | int | int | test.c:89:35:89:35 | d | double d |
|
||||
| test.c:56:3:56:24 | call to defined_with_long_long | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:93:11:93:32 | defined_with_long_long | defined_with_long_long | test.c:56:26:56:28 | 99 | 99 | file://:0:0:0:0 | int | int | test.c:93:44:93:45 | ll | long long ll |
|
||||
| test.c:57:3:57:24 | call to defined_with_long_long | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:93:11:93:32 | defined_with_long_long | defined_with_long_long | test.c:57:26:57:26 | 3 | 3 | file://:0:0:0:0 | int | int | test.c:93:44:93:45 | ll | long long ll |
|
||||
| test.c:59:3:59:21 | call to defined_with_double | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:89:8:89:26 | defined_with_double | defined_with_double | test.c:59:23:59:25 | 2 | 2 | file://:0:0:0:0 | long long | long long | test.c:89:35:89:35 | d | double d |
|
||||
| test.c:60:3:60:24 | call to defined_with_long_long | Calling $@: argument $@ of type $@ is incompatible with parameter $@. | test.c:93:11:93:32 | defined_with_long_long | defined_with_long_long | test.c:60:26:60:31 | 2.499999999999999983e+50 | 2.499999999999999983e+50 | file://:0:0:0:0 | double | double | test.c:93:44:93:45 | ll | long long ll |
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
| test.c:26:3:26:19 | call to not_yet_declared2 | This call has fewer arguments than required by $@. | test.c:24:3:24:3 | not_yet_declared2 | not_yet_declared2 |
|
||||
| test.c:26:3:26:19 | call to not_yet_declared2 | This call has fewer arguments than required by $@. | test.c:54:6:54:22 | not_yet_declared2 | not_yet_declared2 |
|
||||
| test.c:28:3:28:29 | call to declared_empty_defined_with | This call has fewer arguments than required by $@. | test.c:55:6:55:32 | declared_empty_defined_with | declared_empty_defined_with |
|
||||
| test.c:65:10:65:20 | call to dereference | This call has fewer arguments than required by $@. | test.c:68:5:68:15 | dereference | dereference |
|
||||
| test.c:33:3:33:19 | call to not_yet_declared2 | This call has fewer arguments than required by $@. | test.c:31:3:31:3 | not_yet_declared2 | not_yet_declared2 |
|
||||
| test.c:33:3:33:19 | call to not_yet_declared2 | This call has fewer arguments than required by $@. | test.c:66:6:66:22 | not_yet_declared2 | not_yet_declared2 |
|
||||
| test.c:35:3:35:29 | call to declared_empty_defined_with | This call has fewer arguments than required by $@. | test.c:67:6:67:32 | declared_empty_defined_with | declared_empty_defined_with |
|
||||
| test.c:77:10:77:20 | call to dereference | This call has fewer arguments than required by $@. | test.c:80:5:80:15 | dereference | dereference |
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
| test.c:16:3:16:16 | call to declared_empty | This call has more arguments than required by $@. | test.c:1:6:1:19 | declared_empty | declared_empty |
|
||||
| test.c:21:3:21:12 | call to undeclared | This call has more arguments than required by $@. | test.c:20:3:20:3 | undeclared | undeclared |
|
||||
| test.c:23:3:23:19 | call to not_yet_declared1 | This call has more arguments than required by $@. | test.c:23:3:23:3 | not_yet_declared1 | not_yet_declared1 |
|
||||
| test.c:23:3:23:19 | call to not_yet_declared1 | This call has more arguments than required by $@. | test.c:53:6:53:22 | not_yet_declared1 | not_yet_declared1 |
|
||||
| test.c:33:3:33:29 | call to declared_empty_defined_with | This call has more arguments than required by $@. | test.c:55:6:55:32 | declared_empty_defined_with | declared_empty_defined_with |
|
||||
| test.c:23:3:23:16 | call to declared_empty | This call has more arguments than required by $@. | test.c:1:6:1:19 | declared_empty | declared_empty |
|
||||
| test.c:28:3:28:12 | call to undeclared | This call has more arguments than required by $@. | test.c:27:3:27:3 | undeclared | undeclared |
|
||||
| test.c:30:3:30:19 | call to not_yet_declared1 | This call has more arguments than required by $@. | test.c:30:3:30:3 | not_yet_declared1 | not_yet_declared1 |
|
||||
| test.c:30:3:30:19 | call to not_yet_declared1 | This call has more arguments than required by $@. | test.c:65:6:65:22 | not_yet_declared1 | not_yet_declared1 |
|
||||
| test.c:40:3:40:29 | call to declared_empty_defined_with | This call has more arguments than required by $@. | test.c:67:6:67:32 | declared_empty_defined_with | declared_empty_defined_with |
|
||||
|
||||
@@ -5,6 +5,13 @@ void declared_empty_defined_with();
|
||||
void declared_with_pointers();
|
||||
void declared_with_array();
|
||||
|
||||
int k_and_r_func(c,d)
|
||||
char c;
|
||||
double d;
|
||||
{
|
||||
return c + d;
|
||||
}
|
||||
|
||||
struct _s { int a, b; } s;
|
||||
|
||||
int ca[4] = { 1, 2, 3, 4 };
|
||||
@@ -48,6 +55,11 @@ void test() {
|
||||
|
||||
defined_with_long_long('c'); // BAD
|
||||
defined_with_long_long(3); // BAD
|
||||
|
||||
defined_with_double(2LL); // BAD
|
||||
defined_with_long_long(2.5e50); // BAD
|
||||
|
||||
k_and_r_func(2.5, &s); // GOOD
|
||||
}
|
||||
|
||||
void not_yet_declared1();
|
||||
|
||||
@@ -5,4 +5,7 @@ void test() {
|
||||
cpp_varargs(); // GOOD
|
||||
cpp_varargs(1); // GOOD
|
||||
__builtin_constant_p("something"); // GOOD: builtin
|
||||
|
||||
// The following is marked "good" since we are not supposed
|
||||
// to analyze C++ files.
|
||||
}
|
||||
Reference in New Issue
Block a user