+2016-09-29 Jakub Jelinek <jakub@redhat.com>
+
+ Implement P0001R1 - C++17 removal of register storage class specifier
+ * c.opt (Wregister): New warning.
+ * c-opts.c (c_common_post_options): Enable -Wregister by
+ default for C++17.
+
2016-09-29 James Greenhalgh <james.greenhalgh@arm.com>
* c-opts.c (c_common_post_options): Remove special case for
warn_shift_negative_value = (extra_warnings
&& (cxx_dialect >= cxx11 || flag_isoc99));
+ /* -Wregister is enabled by default in C++17. */
+ if (!global_options_set.x_warn_register)
+ warn_register = cxx_dialect >= cxx1z;
+
/* Declone C++ 'structors if -Os. */
if (flag_declone_ctor_dtor == -1)
flag_declone_ctor_dtor = optimize_size;
C ObjC C++ ObjC++ Var(warn_redundant_decls) Warning
Warn about multiple declarations of the same object.
+Wregister
+C++ ObjC++ Var(warn_register) Warning
+Warn about uses of register storage specifier.
+
Wreorder
C++ ObjC++ Var(warn_reorder) Warning LangEnabledBy(C++ ObjC++,Wall)
Warn when the compiler reorders code.
+2016-09-29 Jakub Jelinek <jakub@redhat.com>
+
+ Implement P0001R1 - C++17 removal of register storage class specifier
+ * decl.c (cp_finish_decl): Diagnose register storage class
+ on vars except when used in GNU global or local register variable
+ extension.
+ (grokdeclarator): Diagnose register storage class on parameters.
+ * except.c (expand_start_catch_block): Set DECL_REGISTER only
+ after cp_finish_decl call.
+
2016-09-29 Marek Polacek <polacek@redhat.com>
* rtti.c (involves_incomplete_p): Add fall through comment.
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);
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)
if (init_type != TREE_TYPE (init))
init = build1 (NOP_EXPR, init_type, init);
exp = create_temporary_var (init_type);
- DECL_REGISTER (exp) = 1;
cp_finish_decl (exp, init, /*init_const_expr=*/false,
NULL_TREE, LOOKUP_ONLYCONVERTING);
+ DECL_REGISTER (exp) = 1;
initialize_handler_parm (decl, exp);
}
+2016-09-29 Jakub Jelinek <jakub@redhat.com>
+
+ Implement P0001R1 - C++17 removal of register storage class specifier
+ * c-c++-common/Wvarargs-2.c (foo1): Except new warning for C++17.
+ * c-c++-common/vector-subscript-2.c (vf): Expect new error for
+ C++17.
+ * c-c++-common/vector-subscript-5.c (foo): Don't use register
+ keyword if not __SSE2__.
+ * c-c++-common/Wvarargs.c (foo1, foo3): Expect new warnings for
+ C++17.
+ * g++.dg/compat/struct-layout-1_generate.c (iterative_hash): Remove
+ register keywords.
+ * g++.dg/eh/pr29166.C: Add -Wno-register option.
+ * g++.dg/warn/register-parm-1.C (erroneous_warning,
+ no_erroneous_warning): Expect new warnings for C++17.
+ * g++.dg/warn/register-var-2.C (f): Likewise.
+ * g++.dg/parse/register1.C (f): Expect new error for C++17.
+ * g++.dg/parse/linkage2.C (foo): Likewise.
+ * g++.dg/torture/pr36826.C (CoinMin, CoinMax): Avoid register
+ keyword on parameters for C++17.
+ * g++.dg/cpp1z/register1.C: New test.
+ * g++.dg/cpp1z/register2.C: New test.
+ * g++.dg/cpp1z/register3.C: New test.
+
2016-09-29 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/adx-check.h (main): Simplify feature bit tests.
}
void
-foo1 (int a, register int b, ...)
+foo1 (int a, register int b, ...) // { dg-warning "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
{
va_list vp;
/* 'b' is declared with register storage, but don't warn
}
void
-foo1 (int a, register int b, ...)
+foo1 (int a, register int b, ...) // { dg-warning "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
{
va_list vp;
/* 'b' is declared with register storage, but don't warn
}
void
-foo3 (int a, register int b, ...)
+foo3 (int a, register int b, ...) // { dg-warning "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
{
va_list vp;
/* 'b' is declared with register storage, so warn. */
float vf(int i)
{
- register vector float a;
+ register vector float a; // { dg-error "ISO C++1z does not allow 'register' storage class specifier" "" { target c++1z } }
return a[0];
}
int
foo (int i)
{
- register U u
+#if __SSE2__
+ register
+#endif
+ U u
#if __SSE2__
asm ("xmm0")
#endif
static hashval_t
iterative_hash (const void *k_in /* the key */,
- register size_t length /* the length of the key */,
- register hashval_t initval /* the previous hash, or
- an arbitrary value */)
+ size_t length /* the length of the key */,
+ hashval_t initval /* the previous hash, or
+ an arbitrary value */)
{
- register const unsigned char *k = (const unsigned char *)k_in;
- register hashval_t a,b,c,len;
+ const unsigned char *k = (const unsigned char *)k_in;
+ hashval_t a,b,c,len;
/* Set up the internal state */
len = length;
--- /dev/null
+// P0001R1 - C++17 removal of register keyword
+// { dg-do compile }
+
+#if defined(__i386__) || defined(__x86_64__)
+#define REG1 "ebx"
+#define REG2 "edi"
+#endif
+
+#ifdef REG1
+register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+#endif
+register int b; // { dg-error "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+register int c (); // { dg-error "storage class 'register' invalid for function" }
+int foo (register int d) // { dg-error "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+{
+ return d;
+}
+int bar ()
+{
+#ifdef REG2
+ register int e __asm (REG2); // { dg-bogus "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+#else
+ int e;
+#endif
+ register int f; // { dg-error "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+ e = 6;
+ f = 7;
+ return e + f;
+}
--- /dev/null
+// P0001R1 - C++17 removal of register keyword
+// { dg-do compile }
+// { dg-options "-Wno-register" }
+
+#if defined(__i386__) || defined(__x86_64__)
+#define REG1 "ebx"
+#define REG2 "edi"
+#endif
+
+#ifdef REG1
+register int a __asm (REG1); // { dg-bogus "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+#endif
+register int b; // { dg-bogus "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+register int c (); // { dg-error "storage class 'register' invalid for function" }
+int foo (register int d) // { dg-bogus "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+{
+ return d;
+}
+int bar ()
+{
+#ifdef REG2
+ register int e __asm (REG2); // { dg-bogus "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+#else
+ int e;
+#endif
+ register int f; // { dg-bogus "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
+ e = 6;
+ f = 7;
+ return e + f;
+}
--- /dev/null
+// P0001R1 - C++17 removal of register keyword
+// { dg-do compile { target c++14_down } }
+// { dg-options "-Wregister" }
+
+#if defined(__i386__) || defined(__x86_64__)
+#define REG1 "ebx"
+#define REG2 "edi"
+#endif
+
+#ifdef REG1
+register int a __asm (REG1); // { dg-bogus "'register' storage class specifier used" }
+#endif
+register int b; // { dg-warning "'register' storage class specifier used" }
+register int c (); // { dg-error "storage class 'register' invalid for function" }
+int foo (register int d) // { dg-warning "'register' storage class specifier used" }
+{
+ return d;
+}
+int bar ()
+{
+#ifdef REG2
+ register int e __asm (REG2); // { dg-bogus "'register' storage class specifier used" }
+#else
+ int e;
+#endif
+ register int f; // { dg-warning "'register' storage class specifier used" }
+ e = 6;
+ f = 7;
+ return e + f;
+}
// PR 29166: r4-r7 corrupted when unwinding.
// { dg-do run }
+// { dg-additional-options "-Wno-register" }
class Ex
{
// PR c++/27884
-extern "C" void foo(register int *my_perl);
+extern "C" void foo(register int *my_perl); // { dg-error "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
operator int() { return i; }
};
-C f (register C x)
+C f (register C x) // { dg-error "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
{
return x + 31;
}
+#if __cplusplus > 201402L
+template <class T> T CoinMax(const T x1, const T x2);
+template <class T> T CoinMin(const T x1, const T x2);
+#else
template <class T> T CoinMax(register const T x1, register const T x2);
template <class T> T CoinMin(register const T x1, register const T x2);
+#endif
class CoinIndexedVector;
class ClpModel {
protected:
// PR c++/60955
// { dg-options "-Wextra" }
-unsigned int erroneous_warning(register int a) {
+unsigned int erroneous_warning(register int a) { // { dg-warning "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
if ((a) & 0xff) return 1; else return 0;
}
-unsigned int no_erroneous_warning(register int a) {
+unsigned int no_erroneous_warning(register int a) { // { dg-warning "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } }
if (a & 0xff) return 1; else return 0;
}
void f(void)
{
- register int x;
+ register int x; /* { dg-warning "ISO C\\+\\+1z does not allow 'register' storage class specifier" "" { target c++1z } } */
g(&x); /* { dg-warning "address requested for 'x', which is declared 'register'" } */
}