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.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 3dfa042..65966f8 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6711,6 +6711,19 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
if (type == error_mark_node)
return;
+ /* Warn about register storage specifiers except when in GNU global
+ or local register variable extension. */
+ if (VAR_P (decl) && DECL_REGISTER (decl) && asmspec_tree == NULL_TREE)
+ {
+ if (cxx_dialect >= cxx1z)
+ pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wregister,
+ "ISO C++1z does not allow %<register%> storage "
+ "class specifier");
+ else
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wregister,
+ "%<register%> storage class specifier used");
+ }
+
/* If a name was specified, get the string. */
if (at_namespace_scope_p ())
asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree);
@@ -11634,7 +11647,20 @@ grokdeclarator (const cp_declarator *declarator,
and in case doing stupid register allocation. */
if (storage_class == sc_register)
- DECL_REGISTER (decl) = 1;
+ {
+ DECL_REGISTER (decl) = 1;
+ /* Warn about register storage specifiers on PARM_DECLs. */
+ if (TREE_CODE (decl) == PARM_DECL)
+ {
+ if (cxx_dialect >= cxx1z)
+ pedwarn (DECL_SOURCE_LOCATION (decl), OPT_Wregister,
+ "ISO C++1z does not allow %<register%> storage "
+ "class specifier");
+ else
+ warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wregister,
+ "%<register%> storage class specifier used");
+ }
+ }
else if (storage_class == sc_extern)
DECL_THIS_EXTERN (decl) = 1;
else if (storage_class == sc_static)