aboutsummaryrefslogtreecommitdiff
path: root/tccgen.c
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-04-10 23:44:10 +0300
committerseyko <seyko2@gmail.com>2015-04-10 23:44:10 +0300
commit5c9dde7255b2ecc38df8b31dc0bef16ea71f0757 (patch)
tree1430499c1ce2a69d6d265bada231cc6dbefb5396 /tccgen.c
parent92efee6e52e6ae1a8cad8fa89da2db11b796295f (diff)
downloadtinycc-5c9dde7255b2ecc38df8b31dc0bef16ea71f0757.tar.gz
tinycc-5c9dde7255b2ecc38df8b31dc0bef16ea71f0757.tar.bz2
option to use an old algorithm of the array in struct initialization
This is for a case when no '{' is used in the initialization code. An option name is -fold-struct-init-code. A linux 2.4.26 can't find initrd when compiled with a new algorithm.
Diffstat (limited to 'tccgen.c')
-rw-r--r--tccgen.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/tccgen.c b/tccgen.c
index 9fab0c8..5275b47 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -5575,22 +5575,45 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
struct/union init */
/* XXX: union needs only one init */
+ int par_count = 0;
if (tok == '(') {
AttributeDef ad1;
CType type1;
next();
- if (tok != '(') {
+ if (tcc_state->old_struct_init_code) {
+ /* an old version of struct initialization.
+ It have a problems. But with a new version
+ linux 2.4.26 can't load ramdisk.
+ */
+ while (tok == '(') {
+ par_count++;
+ next();
+ }
+ if (!parse_btype(&type1, &ad1))
+ expect("cast");
+ type_decl(&type1, &ad1, &n, TYPE_ABSTRACT);
+ #if 0
+ if (!is_assignable_types(type, &type1))
+ tcc_error("invalid type for cast");
+ #endif
+ skip(')');
+ }
+ else
+ {
+ if (tok != '(') {
if (!parse_btype(&type1, &ad1))
expect("cast");
type_decl(&type1, &ad1, &n, TYPE_ABSTRACT);
-#if 0
+ #if 0
if (!is_assignable_types(type, &type1))
tcc_error("invalid type for cast");
-#endif
+ #endif
skip(')');
- } else
+ } else
unget_tok(tok);
+ }
}
+
no_oblock = 1;
if (first || tok == '{') {
skip('{');
@@ -5663,6 +5686,10 @@ static void decl_initializer(CType *type, Section *sec, unsigned long c,
}
if (!no_oblock)
skip('}');
+ while (par_count) {
+ skip(')');
+ par_count--;
+ }
} else if (tok == '{') {
next();
decl_initializer(type, sec, c, first, size_only);