mirror of
https://github.com/gcc-mirror/gcc.git
synced 2024-11-21 13:40:47 +00:00
modula2: -Wcase-enum detect singular/plural and use switch during build
This patch generates a singular or plural message relating to the number of enums missing. Use -Wcase-enum when building of the modula-2 libraries and m2/stage2/cc1gm2. gcc/m2/ChangeLog: * Make-lang.in (GM2_FLAGS): Add -Wcase-enum. (GM2_ISO_FLAGS): Add -Wcase-enum. * gm2-compiler/M2CaseList.mod (EnumerateErrors): Issue singular or plural start text prior to the enum list. Remove unused parameter tokenno. (EmitMissingRangeErrors): New procedure. (MissingCaseBounds): Call EmitMissingRangeErrors. (MissingCaseStatementBounds): Call EmitMissingRangeErrors. * gm2-libs-iso/TextIO.mod: Fix spacing. libgm2/ChangeLog: * libm2cor/Makefile.am (libm2cor_la_M2FLAGS): Add -Wcase-enum. * libm2cor/Makefile.in: Regenerate. * libm2iso/Makefile.am (libm2iso_la_M2FLAGS): Add -Wcase-enum. * libm2iso/Makefile.in: Regenerate. * libm2log/Makefile.am (libm2log_la_M2FLAGS): Add -Wcase-enum. * libm2log/Makefile.in: Regenerate. * libm2pim/Makefile.am (libm2pim_la_M2FLAGS): Add -Wcase-enum. * libm2pim/Makefile.in: Regenerate. Signed-off-by: Gaius Mulley <gaiusmod2@gmail.com>
This commit is contained in:
parent
d03773c8ef
commit
3af2af1579
@ -474,18 +474,21 @@ GM2_G=-g -fm2-g
|
||||
GM2_CPP=
|
||||
# GM2_DEBUG_STRMEM=-fcpp
|
||||
GM2_DEBUG_STRMEM=
|
||||
GM2_FLAGS=-Wunused-variable -Wuninit-variable-checking \
|
||||
-fsoft-check-all \
|
||||
-fno-return -Wreturn-type \
|
||||
GM2_FLAGS=-fsoft-check-all \
|
||||
-fno-return \
|
||||
$(GM2_G) $(GM2_O) \
|
||||
-funbounded-by-reference -fpim -fextended-opaque \
|
||||
-Wpedantic-cast -Wpedantic-param-names -ffunction-sections \
|
||||
-fdata-sections $(GM2_CPP) # -fauto-init
|
||||
-Wcase-enum -Wpedantic-cast -Wpedantic-param-names \
|
||||
-Wreturn-type -Wunused-variable -Wuninit-variable-checking \
|
||||
-ffunction-sections -fdata-sections \
|
||||
$(GM2_CPP) # -fauto-init
|
||||
GM2_ISO_FLAGS=-fsoft-check-all $(GM2_G) $(GM2_O) \
|
||||
-fno-return -Wreturn-type \
|
||||
-fno-return \
|
||||
-funbounded-by-reference -fiso -fextended-opaque \
|
||||
-Wpedantic-cast -Wpedantic-param-names -ffunction-sections \
|
||||
-fdata-sections $(GM2_CPP)
|
||||
-Wcase-enum -Wpedantic-cast -Wpedantic-param-names -Wreturn-type \
|
||||
-Wunused-variable -Wuninit-variable-checking \
|
||||
-ffunction-sections -fdata-sections \
|
||||
$(GM2_CPP)
|
||||
GM2_MIN_FLAGS=$(GM2_G) $(GM2_OS) \
|
||||
-funbounded-by-reference -fextended-opaque \
|
||||
-Wpedantic-cast -Wpedantic-param-names -fno-exceptions \
|
||||
|
@ -36,9 +36,11 @@ FROM DynamicStrings IMPORT InitString, InitStringCharStar, ConCat, Mark, KillStr
|
||||
FROM m2tree IMPORT Tree ;
|
||||
FROM m2block IMPORT RememberType ;
|
||||
FROM m2type IMPORT GetMinFrom ;
|
||||
FROM m2expr IMPORT GetIntegerOne ;
|
||||
FROM Storage IMPORT ALLOCATE ;
|
||||
FROM M2Base IMPORT IsExpressionCompatible ;
|
||||
FROM M2Printf IMPORT printf1 ;
|
||||
FROM M2LexBuf IMPORT TokenToLocation ;
|
||||
|
||||
FROM SymbolTable IMPORT NulSym, IsConst, IsFieldVarient, IsRecord, IsRecordField, GetVarientTag, GetType,
|
||||
ForeachLocalSymDo, GetSymName, IsEnumeration, SkipType, NoOfElements, GetNth ;
|
||||
@ -842,16 +844,22 @@ END appendStr ;
|
||||
|
||||
|
||||
(*
|
||||
EnumerateErrors -
|
||||
EnumerateErrors - populate errorString with the contents of enumList.
|
||||
*)
|
||||
|
||||
PROCEDURE EnumerateErrors (tokenno: CARDINAL; enumList: List) ;
|
||||
PROCEDURE EnumerateErrors (enumList: List) ;
|
||||
VAR
|
||||
i, n: CARDINAL ;
|
||||
BEGIN
|
||||
n := NoOfItemsInList (enumList) ;
|
||||
IF (enumList # NIL) AND (n > 0)
|
||||
THEN
|
||||
IF n = 1
|
||||
THEN
|
||||
errorString := InitString ('{%W}the missing enumeration field is: ') ;
|
||||
ELSE
|
||||
errorString := InitString ('{%W}the missing enumeration fields are: ') ;
|
||||
END ;
|
||||
appendEnum (GetItemFromList (enumList, 1)) ;
|
||||
IF n > 1
|
||||
THEN
|
||||
@ -871,6 +879,24 @@ BEGIN
|
||||
END EnumerateErrors ;
|
||||
|
||||
|
||||
(*
|
||||
EmitMissingRangeErrors - emits a singular/plural error message for an enumeration type.
|
||||
*)
|
||||
|
||||
PROCEDURE EmitMissingRangeErrors (tokenno: CARDINAL; type: CARDINAL; set: SetRange) ;
|
||||
BEGIN
|
||||
errorString := NIL ;
|
||||
IF IsEnumeration (type)
|
||||
THEN
|
||||
EnumerateErrors (ErrorRanges (type, set))
|
||||
END ;
|
||||
IF errorString # NIL
|
||||
THEN
|
||||
MetaErrorStringT0 (tokenno, errorString)
|
||||
END
|
||||
END EmitMissingRangeErrors ;
|
||||
|
||||
|
||||
(*
|
||||
MissingCaseBounds - returns true if there were any missing bounds
|
||||
in the varient record case list, c. It will
|
||||
@ -902,7 +928,7 @@ BEGIN
|
||||
MetaErrorT2 (tokenno,
|
||||
'not all variant record alternatives in the {%kCASE} clause are specified, hint you either need to specify each value of {%2ad} or use an {%kELSE} clause',
|
||||
varient, type) ;
|
||||
EnumerateErrors (tokenno, ErrorRanges (type, set))
|
||||
EmitMissingRangeErrors (tokenno, type, set)
|
||||
END ;
|
||||
set := DisposeRanges (set)
|
||||
END
|
||||
@ -944,9 +970,7 @@ BEGIN
|
||||
MetaErrorT1 (tokenno,
|
||||
'not all enumeration values in the {%kCASE} statements are specified, hint you either need to specify each value of {%1Wad} or use an {%kELSE} clause',
|
||||
type) ;
|
||||
errorString := InitString ('{%W}the missing enumeration fields are: ') ;
|
||||
EnumerateErrors (tokenno, ErrorRanges (type, set)) ;
|
||||
MetaErrorStringT0 (tokenno, errorString)
|
||||
EmitMissingRangeErrors (tokenno, type, set)
|
||||
END ;
|
||||
set := DisposeRanges (set)
|
||||
END
|
||||
|
@ -117,7 +117,7 @@ libm2cor_la_M2FLAGS = \
|
||||
-fm2-pathname=m2cor -I. -I$(GM2_SRC)/gm2-libs-coroutines \
|
||||
-fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
|
||||
-fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
|
||||
-fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2cor
|
||||
-fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2cor
|
||||
if TARGET_DARWIN
|
||||
libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup
|
||||
else
|
||||
|
@ -466,7 +466,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
|
||||
@BUILD_CORLIB_TRUE@ -fm2-pathname=m2cor -I. -I$(GM2_SRC)/gm2-libs-coroutines \
|
||||
@BUILD_CORLIB_TRUE@ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
|
||||
@BUILD_CORLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
|
||||
@BUILD_CORLIB_TRUE@ -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2cor
|
||||
@BUILD_CORLIB_TRUE@ -fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2cor
|
||||
|
||||
@BUILD_CORLIB_TRUE@@TARGET_DARWIN_FALSE@libm2cor_la_link_flags =
|
||||
@BUILD_CORLIB_TRUE@@TARGET_DARWIN_TRUE@libm2cor_la_link_flags = -Wl,-undefined,dynamic_lookup
|
||||
|
@ -191,7 +191,7 @@ libm2iso_la_CFLAGS = $(C_INCLUDES) -I. -I.. -I$(GM2_SRC)/gm2-libs-iso -I$(GM2_SR
|
||||
libm2iso_la_M2FLAGS = \
|
||||
-fm2-pathname=m2iso -I. -Ilibm2iso -I$(GM2_SRC)/gm2-libs-iso \
|
||||
-fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
|
||||
-fiso -fextended-opaque -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2iso
|
||||
-fiso -fextended-opaque -fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2iso
|
||||
if TARGET_DARWIN
|
||||
libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup
|
||||
else
|
||||
|
@ -567,7 +567,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
|
||||
@BUILD_ISOLIB_TRUE@libm2iso_la_M2FLAGS = \
|
||||
@BUILD_ISOLIB_TRUE@ -fm2-pathname=m2iso -I. -Ilibm2iso -I$(GM2_SRC)/gm2-libs-iso \
|
||||
@BUILD_ISOLIB_TRUE@ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
|
||||
@BUILD_ISOLIB_TRUE@ -fiso -fextended-opaque -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2iso
|
||||
@BUILD_ISOLIB_TRUE@ -fiso -fextended-opaque -fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2iso
|
||||
|
||||
@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_FALSE@libm2iso_la_link_flags =
|
||||
@BUILD_ISOLIB_TRUE@@TARGET_DARWIN_TRUE@libm2iso_la_link_flags = -Wl,-undefined,dynamic_lookup
|
||||
|
@ -136,7 +136,7 @@ libm2log_la_M2FLAGS = \
|
||||
-fm2-pathname=m2log -I$(GM2_SRC)/gm2-libs-log \
|
||||
-fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
|
||||
-fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
|
||||
-Wreturn-type -fcase -fm2-prefix=m2log
|
||||
-Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2log
|
||||
if TARGET_DARWIN
|
||||
libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup
|
||||
else
|
||||
|
@ -475,7 +475,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
|
||||
@BUILD_LOGLIB_TRUE@ -fm2-pathname=m2log -I$(GM2_SRC)/gm2-libs-log \
|
||||
@BUILD_LOGLIB_TRUE@ -fm2-pathname=m2pim -I$(GM2_SRC)/gm2-libs \
|
||||
@BUILD_LOGLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
|
||||
@BUILD_LOGLIB_TRUE@ -Wreturn-type -fcase -fm2-prefix=m2log
|
||||
@BUILD_LOGLIB_TRUE@ -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2log
|
||||
|
||||
@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_FALSE@libm2log_la_link_flags =
|
||||
@BUILD_LOGLIB_TRUE@@TARGET_DARWIN_TRUE@libm2log_la_link_flags = -Wl,-undefined,dynamic_lookup
|
||||
|
@ -169,7 +169,7 @@ libm2pim_la_CFLAGS = -I. -I.. -I$(GM2_SRC)/gm2-libs -I$(GM2_SRC)/gm2-libs-iso -D
|
||||
libm2pim_la_M2FLAGS = \
|
||||
-fm2-pathname=m2pim -I. -I$(GM2_SRC)/gm2-libs \
|
||||
-fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
|
||||
-fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2pim
|
||||
-fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2pim
|
||||
if TARGET_DARWIN
|
||||
libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup
|
||||
else
|
||||
|
@ -536,7 +536,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
|
||||
@BUILD_PIMLIB_TRUE@libm2pim_la_M2FLAGS = \
|
||||
@BUILD_PIMLIB_TRUE@ -fm2-pathname=m2pim -I. -I$(GM2_SRC)/gm2-libs \
|
||||
@BUILD_PIMLIB_TRUE@ -fm2-pathname=m2iso -I$(GM2_SRC)/gm2-libs-iso \
|
||||
@BUILD_PIMLIB_TRUE@ -fm2-g -g -Wreturn-type -fcase -fm2-prefix=m2pim
|
||||
@BUILD_PIMLIB_TRUE@ -fm2-g -g -Wcase-enum -Wreturn-type -fcase -fm2-prefix=m2pim
|
||||
|
||||
@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_FALSE@libm2pim_la_link_flags =
|
||||
@BUILD_PIMLIB_TRUE@@TARGET_DARWIN_TRUE@libm2pim_la_link_flags = -Wl,-undefined,dynamic_lookup
|
||||
|
Loading…
Reference in New Issue
Block a user