2008-05-17
2008-05-17 22:48:33 by Henrik Grubbström (Grubba) <grubba@grubba.org>
-
6f16cb19dc0f330f99f3c8588916912ddec41acd
(28 lines)
(+21/-7)
[
Show
| Annotate
]
Branch: 7.9
First go at format string checking for sscanf et al.
Added __handle_sscanf_format().
F_SSCANF-nodes are now type checked with new_check_call() (just like ordinary function calls).
new_check_call() now accepts and detects F_LVALUE_LIST nodes as arguments.
Added flag CALL_ARG_LVALUE to indicate that checked arguments are lvalues.
Rev: src/builtin_functions.c:1.664
Rev: src/las.c:1.410
Rev: src/pike_types.c:1.335
Rev: src/pike_types.h:1.117
Rev: src/sscanf.c:1.179
Rev: src/sscanf.h:1.5
2:
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
- || $Id: pike_types.c,v 1.334 2008/05/14 16:02:04 grubba Exp $
+ || $Id: pike_types.c,v 1.335 2008/05/17 22:48:32 grubba Exp $
*/
#include "global.h"
97:
PMOD_EXPORT struct pike_type *zero_type_string;
PMOD_EXPORT struct pike_type *any_type_string;
PMOD_EXPORT struct pike_type *weak_type_string; /* array|mapping|multiset|function */
+ struct pike_type *sscanf_type_string;
+ struct pike_type *sscanf_76_type_string;
#ifdef DO_PIKE_CLEANUP
struct pike_type_location *all_pike_type_locations = NULL;
6701:
/* NOTE: fun_type loses a reference. */
struct pike_type *new_check_call(struct pike_string *fun_name,
struct pike_type *fun_type,
- node *args, INT32 *argno)
+ node *args, INT32 *argno, INT32 flags)
{
struct compilation *c = THIS_COMPILATION;
struct pike_type *tmp = NULL;
struct pike_type *res = NULL;
struct svalue *sval = NULL;
- int flags = 0;
+
CHECK_COMPILER();
debug_malloc_touch(fun_type);
- while (args && (args->token == F_ARG_LIST) && fun_type) {
- fun_type = new_check_call(fun_name, fun_type, CAR(args), argno);
+ while (args &&
+ ((args->token == F_ARG_LIST) || (args->token == F_LVALUE_LIST)) &&
+ fun_type) {
+ if (args->token == F_LVALUE_LIST) flags |= CALL_ARG_LVALUE;
+ fun_type = new_check_call(fun_name, fun_type, CAR(args), argno, flags);
debug_malloc_touch(fun_type);
args = CDR(args);
}
6823: Inside #if defined(PIKE_DEBUG)
fprintf(stderr, " OK.\n");
}
#endif /* PIKE_DEBUG */
- if (c->lex.pragmas & ID_STRICT_TYPES) {
+ if ((c->lex.pragmas & ID_STRICT_TYPES) &&
+ /* FIXME: Strict types not supported for lvalues yet. */
+ !(flags & CALL_ARG_LVALUE)){
if (!(tmp = low_new_check_call(fun_type, args->type,
flags|CALL_STRICT, sval))) {
yywarning("Type mismatch in argument %d to %S.",
7766:
any_type_string = CONSTTYPE(tOr(tVoid,tMix));
weak_type_string = CONSTTYPE(tOr4(tArray,tMultiset,tMapping,
tFuncV(tNone,tZero,tOr(tMix,tVoid))));
+ sscanf_type_string = CONSTTYPE(tFuncV(tStr tAttr("sscanf_format", tStr),
+ tAttr("sscanf_args", tMix), tIntPos));
+ sscanf_76_type_string = CONSTTYPE(tFuncV(tStr tAttr("sscanf_76_format", tStr),
+ tAttr("sscanf_args", tMix), tIntPos));
/* add_ref(weak_type_string); *//* LEAK */
#ifdef PIKE_DEBUG
7816:
any_type_string = NULL;
free_type(weak_type_string);
weak_type_string = NULL;
-
+ free_type(sscanf_type_string);
+ sscanf_type_string = NULL;
+ free_type(sscanf_76_type_string);
+ sscanf_76_type_string = NULL;
#ifdef PIKE_DEBUG
remove_callback(pike_type_gc_callback);
#endif