diff options
Diffstat (limited to 'gcc/cp')
-rw-r--r-- | gcc/cp/constexpr.cc | 13 | ||||
-rw-r--r-- | gcc/cp/decl.cc | 6 |
2 files changed, 10 insertions, 9 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc index a3136ce..ce4ef8e 100644 --- a/gcc/cp/constexpr.cc +++ b/gcc/cp/constexpr.cc @@ -6723,17 +6723,18 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, } if (VAR_P (r) - && (TREE_STATIC (r) || CP_DECL_THREAD_LOCAL_P (r)) + && (TREE_STATIC (r) + || (CP_DECL_THREAD_LOCAL_P (r) && !DECL_REALLY_EXTERN (r))) /* Allow __FUNCTION__ etc. */ && !DECL_ARTIFICIAL (r)) { if (!ctx->quiet) { if (CP_DECL_THREAD_LOCAL_P (r)) - error_at (loc, "control passes through declaration of %qD " + error_at (loc, "control passes through definition of %qD " "with thread storage duration", r); else - error_at (loc, "control passes through declaration of %qD " + error_at (loc, "control passes through definition of %qD " "with static storage duration", r); } *non_constant_p = true; @@ -9188,17 +9189,17 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now, tmp = DECL_EXPR_DECL (t); if (VAR_P (tmp) && !DECL_ARTIFICIAL (tmp)) { - if (CP_DECL_THREAD_LOCAL_P (tmp)) + if (CP_DECL_THREAD_LOCAL_P (tmp) && !DECL_REALLY_EXTERN (tmp)) { if (flags & tf_error) - error_at (DECL_SOURCE_LOCATION (tmp), "%qD declared " + error_at (DECL_SOURCE_LOCATION (tmp), "%qD defined " "%<thread_local%> in %<constexpr%> context", tmp); return false; } else if (TREE_STATIC (tmp)) { if (flags & tf_error) - error_at (DECL_SOURCE_LOCATION (tmp), "%qD declared " + error_at (DECL_SOURCE_LOCATION (tmp), "%qD defined " "%<static%> in %<constexpr%> context", tmp); return false; } diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc index efef1b7..68741bbf 100644 --- a/gcc/cp/decl.cc +++ b/gcc/cp/decl.cc @@ -5774,15 +5774,15 @@ start_decl (const cp_declarator *declarator, && cxx_dialect < cxx23) { bool ok = false; - if (CP_DECL_THREAD_LOCAL_P (decl)) + if (CP_DECL_THREAD_LOCAL_P (decl) && !DECL_REALLY_EXTERN (decl)) error_at (DECL_SOURCE_LOCATION (decl), - "%qD declared %<thread_local%> in %qs function only " + "%qD defined %<thread_local%> in %qs function only " "available with %<-std=c++2b%> or %<-std=gnu++2b%>", decl, DECL_IMMEDIATE_FUNCTION_P (current_function_decl) ? "consteval" : "constexpr"); else if (TREE_STATIC (decl)) error_at (DECL_SOURCE_LOCATION (decl), - "%qD declared %<static%> in %qs function only available " + "%qD defined %<static%> in %qs function only available " "with %<-std=c++2b%> or %<-std=gnu++2b%>", decl, DECL_IMMEDIATE_FUNCTION_P (current_function_decl) ? "consteval" : "constexpr"); |