Kaydet (Commit) 257de659 authored tarafından Colomban Wendling's avatar Colomban Wendling

fortran: Make sure not to index kinds out of bounds

This also makes recent GCC shut up about indexing below the bounds as
it detected the code checked for a negative index yet didn't guard the
actual access.  For now GCC doesn't understand the more comprehensive
check, but it might come back if GCC becomes smart enough.

Anyway, this makes the Assert() more correct, and addition of the
explicit kinds array size makes sure any future kind addition won't
miss its entry.
üst e1988964
......@@ -214,7 +214,7 @@ static boolean NewLine = TRUE;
static unsigned int contextual_fake_count = 0;
/* indexed by tagType */
static kindOption FortranKinds [] = {
static kindOption FortranKinds [TAG_COUNT] = {
{ TRUE, 'b', "block data", "block data"},
{ TRUE, 'c', "macro", "common blocks"},
{ TRUE, 'e', "entry", "entry points"},
......@@ -490,7 +490,7 @@ static boolean isFileScope (const tagType type)
static boolean includeTag (const tagType type)
{
boolean include;
Assert (type != TAG_UNDEFINED);
Assert (type > TAG_UNDEFINED && type < TAG_COUNT);
include = FortranKinds [(int) type].enabled;
if (include && isFileScope (type))
include = Option.include.fileScope;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment