scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit d8b440c914ba19c96d8c8ec6eaaa10bf90352987
parent c7315dfa1117bafcb193d4fbd9cdaa27d08e932d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 31 Oct 2013 21:43:36 +0100

Reduce indentation in sqpecifier

At the moment we know we are not going to continue reading specifiers
we can go out of the loop and the switch, and it will help us to reduce
the ciclomatic complexity.

Diffstat:
Mdecl.c | 50+++++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/decl.c b/decl.c @@ -217,32 +217,36 @@ specifier(register struct ctype *tp, } /* it is not a type name */ default: - if (!tp->defined) { - if (!store->defined && - !qlf->defined && - curctx != CTX_OUTER && - nested_tags == 0) { - return false; - } - warn(options.implicit, - "type defaults to 'int' in declaration"); - } - if (nested_tags > 0 && (qlf->defined || store->defined)) - error("type qualifer or store specifier in field declaration"); - if (!tp->c_signed && !tp->c_unsigned) { - switch (tp->type) { - case CHAR: - if (!options.charsign) { - case BOOL: tp->c_unsigned = 1; - break; - } - case INT: case SHORT: case LONG: case LLONG: - tp->c_signed = 1; - } + goto check_type; + } + } + +check_type: + if (!tp->defined) { + if (!store->defined && + !qlf->defined && + curctx != CTX_OUTER && + nested_tags == 0) { + return false; + } + warn(options.implicit, + "type defaults to 'int' in declaration"); + } + if (nested_tags > 0 && (qlf->defined || store->defined)) + error("type qualifer or store specifier in field declaration"); + + if (!tp->c_signed && !tp->c_unsigned) { + switch (tp->type) { + case CHAR: + if (!options.charsign) { + case BOOL: tp->c_unsigned = 1; + break; } - return true; + case INT: case SHORT: case LONG: case LLONG: + tp->c_signed = 1; } } + return true; } static void