Commit 89e3a3e9 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Detect some forbidden keywords in variable names

such as "integer", "real" which are Ada names
parent 90a79757
......@@ -919,8 +919,8 @@ def compare_types(type_a, type_b): # type -> [warnings]
raise TypeError('Incompatible sizes - size of {} can vary'
elif(int(type_b.Min) >= int(type_a.Min)
and int(type_b.Max) <= int(type_a.Max)):
elif(float(type_b.Min) >= float(type_a.Min)
and float(type_b.Max) <= float(type_a.Max)):
warnings.extend(compare_types(type_a.type, type_b.type))
return warnings
......@@ -1140,6 +1140,11 @@ def primary_variable(root, context):
''' Primary Variable analysis '''
name = getattr(root.getChild(0), 'text', 'error')
errors, warnings = [], []
# Detect reserved keywords
if name.lower() in ('integer', 'real', 'procedure', 'begin', 'end',
'for', 'in', 'out', 'loop'):
errors.append(u"Use of forbidden keyword for a variable name : {}"
possible_constant = is_asn1constant(name)
if possible_constant:
......@@ -1533,6 +1538,7 @@ def conditional_expression(root, context):
warnings.extend(fix_expression_types(expr, context))
expr.exprType = then_expr.exprType
except (AttributeError, TypeError) as err:
#print str(err), expr.inputString
if UNKNOWN_TYPE not in (then_expr.exprType, else_expr.exprType):
errors.append(error(root, str(err)))
......@@ -54,7 +54,8 @@ SDL_BLACKBOLD = ['\\b{word}\\b'.format(word=word) for word in (
SDL_REDBOLD = ['\\b{word}\\b'.format(word=word) for word in (
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment