diff options
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 76 |
1 files changed, 49 insertions, 27 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 0683f26b7a0..9fabde7881b 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2523,8 +2523,12 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) } if (VAR_P (newdecl) - && DECL_THREAD_LOCAL_P (newdecl)) - set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl)); + && CP_DECL_THREAD_LOCAL_P (newdecl)) + { + CP_DECL_THREAD_LOCAL_P (olddecl) = true; + if (!processing_template_decl) + set_decl_tls_model (olddecl, DECL_TLS_MODEL (newdecl)); + } } DECL_UID (olddecl) = olddecl_uid; @@ -2702,14 +2706,14 @@ redeclaration_error_message (tree newdecl, tree olddecl) return NULL; } else if (VAR_P (newdecl) - && DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl) + && CP_DECL_THREAD_LOCAL_P (newdecl) != CP_DECL_THREAD_LOCAL_P (olddecl) && (! DECL_LANG_SPECIFIC (olddecl) || ! CP_DECL_THREADPRIVATE_P (olddecl) - || DECL_THREAD_LOCAL_P (newdecl))) + || CP_DECL_THREAD_LOCAL_P (newdecl))) { /* Only variables can be thread-local, and all declarations must agree on this property. */ - if (DECL_THREAD_LOCAL_P (newdecl)) + if (CP_DECL_THREAD_LOCAL_P (newdecl)) return G_("thread-local declaration of %q#D follows " "non-thread-local declaration"); else @@ -3208,6 +3212,9 @@ struct cp_switch label. We need a tree, rather than simply a hash table, because of the GNU case range extension. */ splay_tree cases; + /* Remember whether there was a case value that is outside the + range of the original type of the controlling expression. */ + bool outside_range_p; }; /* A stack of the currently active switch statements. The innermost @@ -3229,6 +3236,7 @@ push_switch (tree switch_stmt) p->next = switch_stack; p->switch_stmt = switch_stmt; p->cases = splay_tree_new (case_compare, NULL, NULL); + p->outside_range_p = false; switch_stack = p; } @@ -3240,10 +3248,14 @@ pop_switch (void) /* Emit warnings as needed. */ switch_location = EXPR_LOC_OR_LOC (cs->switch_stmt, input_location); + const bool bool_cond_p + = (SWITCH_STMT_TYPE (cs->switch_stmt) + && TREE_CODE (SWITCH_STMT_TYPE (cs->switch_stmt)) == BOOLEAN_TYPE); if (!processing_template_decl) c_do_switch_warnings (cs->cases, switch_location, SWITCH_STMT_TYPE (cs->switch_stmt), - SWITCH_STMT_COND (cs->switch_stmt)); + SWITCH_STMT_COND (cs->switch_stmt), + bool_cond_p, cs->outside_range_p); splay_tree_delete (cs->cases); switch_stack = switch_stack->next; @@ -3308,7 +3320,8 @@ finish_case_label (location_t loc, tree low_value, tree high_value) high_value = case_conversion (type, high_value); r = c_add_case_label (loc, switch_stack->cases, cond, type, - low_value, high_value); + low_value, high_value, + &switch_stack->outside_range_p); /* After labels, make any new cleanups in the function go into their own new (temporary) binding contour. */ @@ -4850,7 +4863,7 @@ start_decl (const cp_declarator *declarator, && DECL_DECLARED_CONSTEXPR_P (current_function_decl)) { bool ok = false; - if (DECL_THREAD_LOCAL_P (decl)) + if (CP_DECL_THREAD_LOCAL_P (decl)) error ("%qD declared %<thread_local%> in %<constexpr%> function", decl); else if (TREE_STATIC (decl)) @@ -7047,7 +7060,7 @@ register_dtor_fn (tree decl) function to do the cleanup. */ dso_parm = (flag_use_cxa_atexit && !targetm.cxx.use_atexit_for_cxa_atexit ()); - ob_parm = (DECL_THREAD_LOCAL_P (decl) || dso_parm); + ob_parm = (CP_DECL_THREAD_LOCAL_P (decl) || dso_parm); use_dtor = ob_parm && CLASS_TYPE_P (type); if (use_dtor) { @@ -7090,7 +7103,7 @@ register_dtor_fn (tree decl) mark_used (cleanup); cleanup = build_address (cleanup); - if (DECL_THREAD_LOCAL_P (decl)) + if (CP_DECL_THREAD_LOCAL_P (decl)) atex_node = get_thread_atexit_node (); else atex_node = get_atexit_node (); @@ -7130,7 +7143,7 @@ register_dtor_fn (tree decl) if (ob_parm) { - if (!DECL_THREAD_LOCAL_P (decl) + if (!CP_DECL_THREAD_LOCAL_P (decl) && targetm.cxx.use_aeabi_atexit ()) { arg1 = cleanup; @@ -7170,7 +7183,7 @@ expand_static_init (tree decl, tree init) return; } - if (DECL_THREAD_LOCAL_P (decl) && DECL_GNU_TLS_P (decl) + if (CP_DECL_THREAD_LOCAL_P (decl) && DECL_GNU_TLS_P (decl) && !DECL_FUNCTION_SCOPE_P (decl)) { if (init) @@ -7199,7 +7212,7 @@ expand_static_init (tree decl, tree init) tree flag, begin; /* We don't need thread-safety code for thread-local vars. */ bool thread_guard = (flag_threadsafe_statics - && !DECL_THREAD_LOCAL_P (decl)); + && !CP_DECL_THREAD_LOCAL_P (decl)); /* Emit code to perform this initialization but once. This code looks like: @@ -7312,7 +7325,7 @@ expand_static_init (tree decl, tree init) finish_then_clause (if_stmt); finish_if_stmt (if_stmt); } - else if (DECL_THREAD_LOCAL_P (decl)) + else if (CP_DECL_THREAD_LOCAL_P (decl)) tls_aggregates = tree_cons (init, decl, tls_aggregates); else static_aggregates = tree_cons (init, decl, static_aggregates); @@ -7729,15 +7742,12 @@ grokfndecl (tree ctype, } if (inlinep & 1) - error ("%<inline%> is not allowed in declaration of friend " - "template specialization %qD", - decl); - if (inlinep & 2) - error ("%<constexpr%> is not allowed in declaration of friend " - "template specialization %qD", - decl); - if (inlinep) - return NULL_TREE; + { + error ("%<inline%> is not allowed in declaration of friend " + "template specialization %qD", + decl); + return NULL_TREE; + } } } @@ -8176,9 +8186,13 @@ grokvardecl (tree type, if (decl_spec_seq_has_spec_p (declspecs, ds_thread)) { if (DECL_EXTERNAL (decl) || TREE_STATIC (decl)) - set_decl_tls_model (decl, decl_default_tls_model (decl)); + { + CP_DECL_THREAD_LOCAL_P (decl) = true; + if (!processing_template_decl) + set_decl_tls_model (decl, decl_default_tls_model (decl)); + } if (declspecs->gnu_thread_keyword_p) - DECL_GNU_TLS_P (decl) = true; + SET_DECL_GNU_TLS_P (decl); } /* If the type of the decl has no linkage, make sure that we'll @@ -10851,9 +10865,11 @@ grokdeclarator (const cp_declarator *declarator, if (thread_p) { - set_decl_tls_model (decl, decl_default_tls_model (decl)); + CP_DECL_THREAD_LOCAL_P (decl) = true; + if (!processing_template_decl) + set_decl_tls_model (decl, decl_default_tls_model (decl)); if (declspecs->gnu_thread_keyword_p) - DECL_GNU_TLS_P (decl) = true; + SET_DECL_GNU_TLS_P (decl); } if (constexpr_p && !initialized) @@ -14314,6 +14330,12 @@ finish_function (int flags) function. */ maybe_warn_unused_local_typedefs (); + /* Possibly warn about unused parameters. */ + if (warn_unused_parameter + && !processing_template_decl + && !DECL_CLONED_FUNCTION_P (fndecl)) + do_warn_unused_parameter (fndecl); + /* Genericize before inlining. */ if (!processing_template_decl) { |