예제 #1
0
void expr_assign_const_check(expr *e, where *w)
{
	struct_union_enum_st *su;

	if(type_is_const(e->tree_type)){
		fold_had_error = 1;
		warn_at_print_error(w, "can't modify const expression %s",
				expr_str_friendly(e));
	}else if((su = type_is_s_or_u(e->tree_type)) && su->contains_const){
		fold_had_error = 1;
		warn_at_print_error(w, "can't assign struct - contains const member");
	}
}
예제 #2
0
파일: asm.c 프로젝트: 8l/ucc-c-compiler
void asm_declare_decl_init(decl *d)
{
	enum section_type sec;

	if((d->store & STORE_MASK_STORE) == store_extern){
		asm_predeclare_extern(d);
		return;
	}

	sec = type_is_const(d->ref) ? SECTION_RODATA : SECTION_DATA;

	if(d->bits.var.init.dinit && !decl_init_is_zero(d->bits.var.init.dinit)){
		asm_nam_begin(sec, d);
		asm_declare_init(sec, d->bits.var.init.dinit, d->ref);
		asm_out_section(sec, "\n");

	}else if(d->bits.var.init.compiler_generated && fopt_mode & FOPT_COMMON){
		const char *common_prefix = "comm ";

		/* section doesn't matter */
		sec = SECTION_BSS;

		if(decl_linkage(d) == linkage_internal){
			if(AS_SUPPORTS_LOCAL_COMMON){
				asm_out_section(sec, ".local %s\n", decl_asm_spel(d));
			}else{
				common_prefix = "zerofill __DATA,__bss,";
			}
		}

		asm_out_section(sec, ".%s%s,%u,%u\n",
				common_prefix,
				decl_asm_spel(d), decl_size(d), decl_align(d));

	}else{
		/* always resB, since we use decl_size() */
		asm_nam_begin(SECTION_BSS, d);
		asm_reserve_bytes(SECTION_BSS, decl_size(d));
	}
}