[qfcc] Catch declarations of arrays of class

They're still static instances.
This commit is contained in:
Bill Currie 2020-03-30 18:55:04 +09:00
parent 101574e697
commit 0de9b02726
4 changed files with 17 additions and 3 deletions

View file

@ -140,7 +140,7 @@ new_def (const char *name, type_t *type, defspace_t *space,
if (!space && storage != sc_extern)
internal_error (0, "non-external def with no storage space");
if (is_class (type)) {
if (is_class (type) || (is_array (type) && is_class(type->t.array.type))) {
error (0, "statically allocated instance of class %s",
type->t.class->name);
return def;
@ -157,7 +157,7 @@ new_def (const char *name, type_t *type, defspace_t *space,
}
if (alignment < 1) {
print_type (type);
internal_error (0, "temp type has no alignment");
internal_error (0, "type has no alignment");
}
def->offset = defspace_alloc_aligned_loc (space, size, alignment);
}

View file

@ -81,6 +81,7 @@ test_progs_dat=\
fail_progs_dat=
test_build_errors=\
classarray.r \
double-demote-float.r \
double-demote-float-ainit.r \
double-demote-float-ginit.r \
@ -208,6 +209,9 @@ double.run: Makefile build-run
include ./$(DEPDIR)/double.Qo # am--include-marker
r_depfiles_remade += ./$(DEPDIR)/double.Qo
classarray.run$(EXEEXT): classarray.r Makefile build-compile-fail-run
@$(srcdir)/build-compile-fail-run $@ $(QFCC) $(QCFLAGS) $<
double-demote-int.run$(EXEEXT): double-demote-int.r Makefile build-compile-fail-run
@$(srcdir)/build-compile-fail-run $@ $(QFCC) $(QCFLAGS) $<

View file

@ -5,7 +5,7 @@ shift
cat > $script <<EOF
#! /bin/sh
# compile must fail
# compile must fail with a normal error
$@
if test \$? != 1; then
exit 1

View file

@ -0,0 +1,10 @@
@interface foo
{
id isa;
}
@end
void bar ()
{
foo foos[1];
}