aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/evaluate.c
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-31 00:04:40 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-03-31 02:27:12 +0200
commit6cdbfb0b6778f0b788222974b55547967f25115f (patch)
tree71406e5f9e594931d646d8d4a0cfbca420fe1ad6 /evaluate.c
parente9b6fdfda4352452649618ee9482b6eae19b126a (diff)
downloadsparse-6cdbfb0b6778f0b788222974b55547967f25115f.tar.gz
constexpr: collect storage modifiers of initializers
This is a preparatory step for checking the constness of initializers of static storage duration objects; Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'evaluate.c')
-rw-r--r--evaluate.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/evaluate.c b/evaluate.c
index 07edda41..138ee1dd 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2451,13 +2451,13 @@ static struct expression *next_designators(struct expression *old,
}
static int handle_initializer(struct expression **ep, int nested,
- int class, struct symbol *ctype);
+ int class, struct symbol *ctype, unsigned long mods);
/*
* deal with traversing subobjects [6.7.8(17,18,20)]
*/
static void handle_list_initializer(struct expression *expr,
- int class, struct symbol *ctype)
+ int class, struct symbol *ctype, unsigned long mods)
{
struct expression *e, *last = NULL, *top = NULL, *next;
int jumped = 0;
@@ -2515,7 +2515,8 @@ found:
else
v = &top->ident_expression;
- if (handle_initializer(v, 1, lclass, top->ctype))
+ mods |= ctype->ctype.modifiers & MOD_STORAGE;
+ if (handle_initializer(v, 1, lclass, top->ctype, mods))
continue;
if (!(lclass & TYPE_COMPOUND)) {
@@ -2608,7 +2609,7 @@ static struct expression *handle_scalar(struct expression *e, int nested)
* until we dig into the inner struct.
*/
static int handle_initializer(struct expression **ep, int nested,
- int class, struct symbol *ctype)
+ int class, struct symbol *ctype, unsigned long mods)
{
int is_string = is_string_type(ctype);
struct expression *e = *ep, *p;
@@ -2648,7 +2649,7 @@ static int handle_initializer(struct expression **ep, int nested,
goto String;
}
}
- handle_list_initializer(e, class, ctype);
+ handle_list_initializer(e, class, ctype, mods);
return 1;
}
@@ -2696,7 +2697,7 @@ static void evaluate_initializer(struct symbol *ctype, struct expression **ep)
{
struct symbol *type;
int class = classify_type(ctype, &type);
- if (!handle_initializer(ep, 0, class, ctype))
+ if (!handle_initializer(ep, 0, class, ctype, 0))
expression_error(*ep, "invalid initializer");
}