diff options
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5b8e6a22b01..aab2019f9cd 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4549,8 +4549,6 @@ push_throw_library_fn (tree name, tree type) void fixup_anonymous_aggr (tree t) { - tree *q; - /* Wipe out memory of synthesized methods. */ TYPE_HAS_USER_CONSTRUCTOR (t) = 0; TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 0; @@ -4559,29 +4557,12 @@ fixup_anonymous_aggr (tree t) TYPE_HAS_COPY_ASSIGN (t) = 0; TYPE_HAS_CONST_COPY_ASSIGN (t) = 0; - /* Splice the implicitly generated functions out of the TYPE_METHODS - list. */ - q = &TYPE_METHODS (t); - while (*q) - { - if (DECL_ARTIFICIAL (*q)) - *q = TREE_CHAIN (*q); - else - q = &DECL_CHAIN (*q); - } - - /* ISO C++ 9.5.3. Anonymous unions may not have function members. */ - if (TYPE_METHODS (t)) - { - tree decl = TYPE_MAIN_DECL (t); - - if (TREE_CODE (t) != UNION_TYPE) - error_at (DECL_SOURCE_LOCATION (decl), - "an anonymous struct cannot have function members"); - else - error_at (DECL_SOURCE_LOCATION (decl), - "an anonymous union cannot have function members"); - } + /* Splice the implicitly generated functions out of TYPE_FIELDS. */ + for (tree probe, *prev_p = &TYPE_FIELDS (t); (probe = *prev_p);) + if (TREE_CODE (probe) == FUNCTION_DECL && DECL_ARTIFICIAL (probe)) + *prev_p = DECL_CHAIN (probe); + else + prev_p = &DECL_CHAIN (probe); /* Anonymous aggregates cannot have fields with ctors, dtors or complex assignment operators (because they cannot have these methods themselves). @@ -7602,6 +7583,7 @@ declare_global_var (tree name, tree type) TREE_PUBLIC (decl) = 1; DECL_EXTERNAL (decl) = 1; DECL_ARTIFICIAL (decl) = 1; + DECL_CONTEXT (decl) = FROB_CONTEXT (global_namespace); /* If the user has explicitly declared this variable (perhaps because the code we are compiling is part of a low-level runtime library), then it is possible that our declaration will be merged @@ -9501,7 +9483,8 @@ compute_array_index_type (tree name, tree size, tsubst_flags_t complain) stabilize_vla_size (itype); - if (sanitize_flags_p (SANITIZE_VLA)) + if (sanitize_flags_p (SANITIZE_VLA) + && current_function_decl != NULL_TREE) { /* We have to add 1 -- in the ubsan routine we generate LE_EXPR rather than LT_EXPR. */ |