mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
Disallow defining macros whose names start with "__" or "GL_".
The GLSL specification reserves these for future use.
This commit is contained in:
parent
e4b2731a25
commit
2ab0b13dd9
1 changed files with 20 additions and 0 deletions
|
|
@ -1344,6 +1344,22 @@ _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
|
|||
_token_list_print (list);
|
||||
}
|
||||
|
||||
void
|
||||
_check_for_reserved_macro_name (const char *identifier)
|
||||
{
|
||||
/* According to the GLSL specification, macro names starting with "__"
|
||||
* or "GL_" are reserved for future use. So, don't allow them.
|
||||
*/
|
||||
if (strncmp(identifier, "__", 2) == 0) {
|
||||
fprintf (stderr, "Error: Macro names starting with \"__\" are reserved.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (strncmp(identifier, "GL_", 3) == 0) {
|
||||
fprintf (stderr, "Error: Macro names starting with \"GL_\" are reserved.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_define_object_macro (glcpp_parser_t *parser,
|
||||
const char *identifier,
|
||||
|
|
@ -1351,6 +1367,8 @@ _define_object_macro (glcpp_parser_t *parser,
|
|||
{
|
||||
macro_t *macro;
|
||||
|
||||
_check_for_reserved_macro_name(identifier);
|
||||
|
||||
macro = xtalloc (parser, macro_t);
|
||||
|
||||
macro->is_function = 0;
|
||||
|
|
@ -1369,6 +1387,8 @@ _define_function_macro (glcpp_parser_t *parser,
|
|||
{
|
||||
macro_t *macro;
|
||||
|
||||
_check_for_reserved_macro_name(identifier);
|
||||
|
||||
macro = xtalloc (parser, macro_t);
|
||||
|
||||
macro->is_function = 1;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue