aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index a44f172..b5d689a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -5470,6 +5470,13 @@ start_decl_1 (tree decl, bool initialized)
cp_apply_type_quals_to_decl (cp_type_quals (type), decl);
}
+ if (is_global_var (decl))
+ {
+ type_context_kind context = (DECL_THREAD_LOCAL_P (decl)
+ ? TCTX_THREAD_STORAGE
+ : TCTX_STATIC_STORAGE);
+ verify_type_context (input_location, context, TREE_TYPE (decl));
+ }
if (initialized)
/* Is it valid for this decl to have an initializer at all? */
{
@@ -6535,6 +6542,11 @@ check_array_initializer (tree decl, tree type, tree init)
error ("elements of array %q#T have incomplete type", type);
return true;
}
+
+ location_t loc = (decl ? location_of (decl) : input_location);
+ if (!verify_type_context (loc, TCTX_ARRAY_ELEMENT, element_type))
+ return true;
+
/* A compound literal can't have variable size. */
if (init && !decl
&& ((COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type)))
@@ -7482,6 +7494,8 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
if (VAR_P (decl)
&& DECL_CLASS_SCOPE_P (decl)
+ && verify_type_context (DECL_SOURCE_LOCATION (decl),
+ TCTX_STATIC_STORAGE, type)
&& DECL_INITIALIZED_IN_CLASS_P (decl))
check_static_variable_definition (decl, type);
@@ -10550,6 +10564,10 @@ create_array_type_for_decl (tree name, tree type, tree size, location_t loc)
break;
}
+ if (!verify_type_context (name ? loc : input_location,
+ TCTX_ARRAY_ELEMENT, type))
+ return error_mark_node;
+
/* [dcl.array]
The constant expressions that specify the bounds of the arrays
@@ -13254,6 +13272,14 @@ grokdeclarator (const cp_declarator *declarator,
decl = NULL_TREE;
}
}
+ else if (!verify_type_context (input_location,
+ staticp
+ ? TCTX_STATIC_STORAGE
+ : TCTX_FIELD, type))
+ {
+ type = error_mark_node;
+ decl = NULL_TREE;
+ }
else
{
if (friendp)