Exemplo n.º 1
0
static void handle_attribute_visibility(const attribute_t *attribute,
                                        entity_t *entity)
{
	/* This isn't really correct, the backend should provide a list of machine
	 * specific modes (according to gcc philosophy that is...) */
	string_t const *const string = get_argument_string(attribute->a.arguments);
	if (string == NULL) {
		errorf(&attribute->pos, "__attribute__((visibility(X))) requires a string argument");
		return;
	}
	elf_visibility_t visibility = get_elf_visibility_from_string(string->begin);
	if (visibility == ELF_VISIBILITY_ERROR) {
		errorf(&attribute->pos, "unknown visibility type '%S'", string);
		return;
	}

	switch (entity->kind) {
	case ENTITY_VARIABLE:
		entity->variable.elf_visibility = visibility;
		break;
	case ENTITY_FUNCTION:
		entity->function.elf_visibility = visibility;
		break;

	default:
		warningf(WARN_OTHER, &attribute->pos, "visibility attribute specification on %N ignored", entity);
		break;
	}
}
Exemplo n.º 2
0
static void handle_attribute_alias(const attribute_t *attribute,
                                   entity_t *entity)
{
	const attribute_argument_t *argument = attribute->a.arguments;
	string_t const *const string = get_argument_string(argument);
	if (string == NULL) {
		errorf(&attribute->pos, "attribute 'alias' requires a string argument");
		return;
	}
	symbol_t *const symbol = symbol_table_insert(string->begin);
	switch (entity->kind) {
	case ENTITY_VARIABLE:
		entity->variable.alias.symbol = symbol;
		break;
	case ENTITY_FUNCTION:
		entity->function.alias.symbol = symbol;
		break;
	default:
		warningf(WARN_OTHER, &attribute->pos, "alias attribute on %N ignored",
		         entity);
		return;
	}
	declaration_t *decl = &entity->declaration;
	if (decl->storage_class == STORAGE_CLASS_EXTERN) {
		/* code generator will ignore the extern declaration */
		warningf(WARN_OTHER, &entity->base.pos,
		         "extern storage class ignored for alias %N", entity);
	}

	ARR_APP1(entity_t*, alias_entities, entity);
}
Exemplo n.º 3
0
string_t const *get_deprecated_string(attribute_t const *attribute)
{
	for ( ; attribute != NULL; attribute = attribute->next) {
		if (attribute->kind == ATTRIBUTE_MS_DEPRECATED)
			return get_argument_string(attribute->a.arguments);
	}
	return NULL;
}
Exemplo n.º 4
0
int
parse_section(struct rcfile *f, const char *sect_name, int sectno)
{
	struct nandsim_key *key;
	struct nandsim_section *sect = (struct nandsim_section *)&sections;
	int getres = 0;

	while (1) {
		if (sect == NULL)
			return (EINVAL);

		if (strcmp(sect->name, sect_name) == 0)
			break;
		else
			sect++;
	}
	key = sect->keys;
	do {
		debug("->Section: %s, Key: %s, type: %d, size: %d",
		    sect_name, key->keyname, TYPE(key->valuetype),
		    SIZE(key->valuetype)/2);

		switch (TYPE(key->valuetype)) {
		case VALUE_UINT:
			/* Single int value */
			getres = get_argument_int(sect_name, sectno, key, f);

			if (getres != 0)
				return (getres);

			break;
		case VALUE_UINTARRAY:
			/* Array of ints */
			getres = get_argument_intarray(sect_name,
			    sectno, key, f);

			if (getres != 0)
				return (getres);

			break;
		case VALUE_STRING:
			/* Array of chars */
			getres = get_argument_string(sect_name, sectno, key,
			    f);

			if (getres != 0)
				return (getres);

			break;
		case VALUE_BOOL:
			/* Boolean value (true/false/on/off/yes/no) */
			getres = get_argument_bool(sect_name, sectno, key,
			    f);

			if (getres != 0)
				return (getres);

			break;
		}
	} while ((++key)->keyname != NULL);

	return (0);
}