static void cb_def_pragma (cpp_reader *pfile, source_location loc) { /* Issue a warning message if we have been asked to do so. Ignore unknown pragmas in system headers unless an explicit -Wunknown-pragmas has been given. */ if (warn_unknown_pragmas > in_system_header) { const unsigned char *space, *name; const cpp_token *s; #ifndef USE_MAPPED_LOCATION location_t fe_loc; const struct line_map *map = linemap_lookup (&line_table, loc); fe_loc.file = map->to_file; fe_loc.line = SOURCE_LINE (map, loc); #else location_t fe_loc = loc; #endif space = name = (const unsigned char *) ""; s = cpp_get_token (pfile); if (s->type != CPP_EOF) { space = cpp_token_as_text (pfile, s); s = cpp_get_token (pfile); if (s->type == CPP_NAME) name = cpp_token_as_text (pfile, s); } warning (OPT_Wunknown_pragmas, "%Hignoring #pragma %s %s", &fe_loc, space, name); } }
/* handler function for the config pragma */ void mchp_handle_config_pragma (struct cpp_reader *pfile) { enum cpp_ttype tok; tree tok_value; static int shown_no_config_warning = 0; /* If we're compiling for the default device, we don't process configuration words */ if (!mchp_processor_string) { error ("#pragma config directive not available for the default generic device, %s", mchp_processor_string); CLEAR_REST_OF_INPUT_LINE(); return; } if (!mchp_config_data_dir) { error ("Configuration-word data directory not specified " "but required for #pragma config directive"); CLEAR_REST_OF_INPUT_LINE(); return; } /* the first time we see a config pragma, we need to load the configuration word data from the definition file. */ if (!mchp_configuration_values) { /* alloc space for the filename: directory + '/' + "configuration.data" */ char *fname = (char*)alloca (strlen (mchp_config_data_dir) + 1 + strlen (MCHP_CONFIGURATION_DATA_FILENAME)); strcpy (fname, mchp_config_data_dir); if (fname [strlen (fname) - 1] != '/' && fname [strlen (fname) - 1] != '\\') strcat (fname, "/"); strcat (fname, MCHP_CONFIGURATION_DATA_FILENAME); if (mchp_load_configuration_definition (fname)) { if (!shown_no_config_warning) { shown_no_config_warning = 1; warning (0, "configuration word information not available for " "this processor. #pragma config is ignored."); } CLEAR_REST_OF_INPUT_LINE(); return; } } /* The payload for the config pragma is a comma delimited list of "setting = value" pairs. Both the setting and the value must be valid C identifiers. */ tok = pragma_lex (&tok_value); while (1) { const cpp_token *raw_token; const char *setting_name; const char *value_name; /* the current token should be the setting name */ if (tok != CPP_NAME) { error ("configuration setting name expected in configuration pragma"); break; } setting_name = IDENTIFIER_POINTER (tok_value); /* the next token should be the '=' */ tok = pragma_lex (&tok_value); if (tok != CPP_EQ) { error ("'=' expected in configuration pragma"); break; } /* now we have the value name. We don't use pragma_lex() to get this one since we don't want the additional interpretation going on there. i.e., converting integers from the string. */ raw_token = cpp_get_token (pfile); if (raw_token->type == CPP_NAME) { /* value_name = IDENTIFIER_POINTER ( HT_IDENT_TO_GCC_IDENT ( HT_NODE (raw_token->val.node))); space? */ value_name = cpp_token_as_text (pfile, raw_token); } else if (raw_token->type == CPP_NUMBER) { value_name = (char*)raw_token->val.str.text; } else { error ("configuration value name expected in configuration pragma"); break; } mchp_handle_configuration_setting (setting_name, value_name); /* if the next token is ',' then we have another setting. */ tok = pragma_lex (&tok_value); if (tok == CPP_COMMA) tok = pragma_lex (&tok_value); /* if it's EOF, we're done */ else if (tok == CPP_EOF) break; /* otherwise, we have spurious input */ else { error ("',' or end of line expected in configuration pragma"); break; } } /* if we ended for any reason other than end of line, we have an error. Any needed diagnostic should have already been issued, so just clear the rest of the data on the line. */ if (tok != CPP_EOF) CLEAR_REST_OF_INPUT_LINE(); }