#define TYPE_SPECIFIER_COUNT 32
+/**
+ * Check if the given identifier is legal.
+ */
+static GLboolean
+legal_identifier(slang_atom name)
+{
+ /* "gl_" is a reserved prefix */
+ if (_mesa_strncmp((char *) name, "gl_", 3) == 0) {
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+}
+
+
/**
* Allocate storage for a variable of 'size' bytes from given pool.
* Return the allocated address for the variable.
o->type = SLANG_OPER_VARIABLE_DECL;
o->locals->outer_scope = O->vars;
o->a_id = O->vars->variables[i]->a_name;
+
+ if (!legal_identifier(o->a_id)) {
+ slang_info_log_error(C->L, "illegal variable name '%s'",
+ (char *) o->a_id);
+ return 0;
+ }
}
}
}
return 0;
}
+
static int
parse_function_prototype(slang_parse_ctx * C, slang_output_ctx * O,
slang_function * func)
return 0;
}
+ if (!legal_identifier(func->header.a_name)) {
+ slang_info_log_error(C->L, "illegal function name '%s'",
+ (char *) func->header.a_name);
+ return 0;
+ }
+
/* parse function parameters */
while (*C->I++ == PARAMETER_NEXT) {
slang_variable *p = slang_variable_scope_grow(func->parameters);