Skip to content

Commit e36c31c

Browse files
committed
Fix -Wswitch, -Wparentheses, -Wdangling-else warnings in gpre/sqe
+ constexpr
1 parent b28760c commit e36c31c

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/gpre/sqe.cpp

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ struct ops
128128
nod_t rel_negation;
129129
};
130130

131-
static const ops rel_ops[] =
131+
static constexpr ops rel_ops[] =
132132
{
133133
{ nod_eq, KW_EQ, nod_ne },
134134
{ nod_eq, KW_EQUALS, nod_ne },
@@ -146,7 +146,7 @@ static const ops rel_ops[] =
146146
};
147147

148148
#ifdef NOT_USED_OR_REPLACED
149-
static const ops scalar_stat_ops[] =
149+
static constexpr ops scalar_stat_ops[] =
150150
{
151151
{ nod_count, KW_COUNT, nod_any },
152152
{ nod_max, KW_MAX, nod_any },
@@ -158,7 +158,7 @@ static const ops scalar_stat_ops[] =
158158
};
159159
#endif
160160

161-
static const ops stat_ops[] =
161+
static constexpr ops stat_ops[] =
162162
{
163163
{ nod_agg_count, KW_COUNT, nod_any },
164164
{ nod_agg_max, KW_MAX, nod_any },
@@ -171,7 +171,7 @@ static const ops stat_ops[] =
171171
{ nod_ansi_all, KW_none, nod_ansi_all }
172172
};
173173

174-
static const nod_t relationals[] =
174+
static constexpr nod_t relationals[] =
175175
{
176176
nod_eq, nod_ne, nod_gt, nod_ge, nod_le, nod_lt, nod_containing,
177177
nod_starting, nod_matches, nod_any, nod_missing, nod_equiv, nod_between, nod_like,
@@ -640,7 +640,7 @@ gpre_nod* SQE_field(gpre_req* request, bool aster_ok)
640640
SQL_resolve_identifier("<Column Name>", NULL, NAME_SIZE);
641641
for (context = request->req_contexts; context; context = context->ctx_next)
642642
{
643-
if (reference->ref_field = MET_context_field(context, gpreGlob.token_global.tok_string))
643+
if ((reference->ref_field = MET_context_field(context, gpreGlob.token_global.tok_string)))
644644
{
645645
if (SQL_DIALECT_V5 == gpreGlob.sw_sql_dialect)
646646
{
@@ -1046,7 +1046,7 @@ bool SQE_resolve(gpre_nod** node_ptr, gpre_req* request, gpre_rse* selection)
10461046
{
10471047
for (SSHORT i = 0; i < selection->rse_count; i++)
10481048
{
1049-
if (field = resolve(node, selection->rse_context[i], &context, &slice_action))
1049+
if ((field = resolve(node, selection->rse_context[i], &context, &slice_action)))
10501050
break;
10511051
}
10521052
}
@@ -1445,15 +1445,15 @@ static gpre_fld* get_ref( gpre_nod* expr)
14451445
gpre_nod** ptr = expr->nod_arg;
14461446
for (const gpre_nod* const* const end = ptr + expr->nod_count; ptr < end; ptr++)
14471447
{
1448-
if (field = get_ref(*ptr))
1448+
if ((field = get_ref(*ptr)))
14491449
return field;
14501450
}
14511451
break;
14521452
}
14531453

14541454
// Begin date/time/timestamp support
14551455
case nod_extract:
1456-
if (field = get_ref(expr->nod_arg[1]))
1456+
if ((field = get_ref(expr->nod_arg[1])))
14571457
return field;
14581458
break;
14591459
// End date/time/timestamp support
@@ -1463,6 +1463,9 @@ static gpre_fld* get_ref( gpre_nod* expr)
14631463
gpre_nod* node = element->mel_expr;
14641464
return get_ref(node);
14651465
}
1466+
default:
1467+
// no specific handling
1468+
break;
14661469
}
14671470

14681471
return 0;
@@ -1730,7 +1733,7 @@ static gpre_ctx* par_alias_list( gpre_req* request, gpre_nod* alias_list)
17301733
continue;
17311734
if (!context->ctx_relation)
17321735
continue;
1733-
if (relation = par_base_table(request, context->ctx_relation, (const TEXT*) *arg))
1736+
if ((relation = par_base_table(request, context->ctx_relation, (const TEXT*) *arg)))
17341737
{
17351738
break;
17361739
}
@@ -2400,6 +2403,8 @@ static gpre_nod* par_plan_item(gpre_req* request, bool /*aster_ok*/, USHORT* /*p
24002403
case KW_MERGE:
24012404
case KW_LEFT_PAREN:
24022405
return par_plan(request);
2406+
default:
2407+
break;
24032408
}
24042409

24052410
// parse the list of one or more table names or
@@ -2877,7 +2882,7 @@ static gpre_rse* par_rse(gpre_req* request, gpre_nod* fields, bool distinct)
28772882
int count = 0;
28782883
gpre_ctx* context;
28792884
do {
2880-
if (context = par_joined_relation(request))
2885+
if ((context = par_joined_relation(request)))
28812886
{
28822887
MSC_push((gpre_nod*) context, &stack);
28832888
count++;
@@ -3209,6 +3214,7 @@ static gpre_nod* par_udf( gpre_req* request)
32093214
{
32103215
udf* tmp_udf = MET_get_udf(db, gpreGlob.token_global.tok_string);
32113216
if (tmp_udf)
3217+
{
32123218
if (an_udf)
32133219
{
32143220
// udf was found in more than one database
@@ -3221,6 +3227,7 @@ static gpre_nod* par_udf( gpre_req* request)
32213227
an_udf = tmp_udf;
32223228
request->req_database = db;
32233229
}
3230+
}
32243231
}
32253232
}
32263233

@@ -3552,6 +3559,8 @@ static gpre_nod* post_fields( gpre_nod* node, map* to_map)
35523559
node->nod_arg[1] = post_fields(node->nod_arg[1], to_map);
35533560
break;
35543561
// End date/time/timestamp support
3562+
default:
3563+
break;
35553564
}
35563565

35573566
return node;
@@ -3766,6 +3775,8 @@ static gpre_fld* resolve(gpre_nod* node,
37663775
if (symbol->sym_object == context)
37673776
field = MET_context_field(context, f_token->tok_string);
37683777
break;
3778+
default:
3779+
break;
37693780
}
37703781
}
37713782

@@ -3894,6 +3905,8 @@ static void set_ref( gpre_nod* expr, gpre_fld* field_ref)
38943905
set_ref(expr->nod_arg[1], field_ref);
38953906
break;
38963907
// End date/time/timestamp support
3908+
default:
3909+
break;
38973910
}
38983911
}
38993912

@@ -3969,6 +3982,8 @@ static bool validate_references(const gpre_nod* fields, const gpre_nod* group_by
39693982
case nod_agg_average:
39703983
case nod_aggregate:
39713984
return false;
3985+
default:
3986+
break;
39723987
}
39733988

39743989
if (fields->nod_type == nod_any || fields->nod_type == nod_ansi_any ||

0 commit comments

Comments
 (0)