+2011-07-22 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ Warn about the use of final/override in non-c++0x mode, and
+ add __final for non-c++0x mode.
+ * cp-tree.h (cpp0x_warn_str): Add CPP0X_OVERRIDE_CONTROLS.
+ * error.c (maybe_warn_cpp0x): Adjust.
+ * parser.c (cp_parser_virt_specifier_seq_opt): Use it. Add
+ '__final' as a non-c++0x alternative for 'final'.
+
2011-07-22 Jason Merrill <jason@redhat.com>
Mark Glisse <marc.glisse@normalesup.org>
/* defaulted and deleted functions */
CPP0X_DEFAULTED_DELETED,
/* inline namespaces */
- CPP0X_INLINE_NAMESPACES
+ CPP0X_INLINE_NAMESPACES,
+ /* override controls, override/final */
+ CPP0X_OVERRIDE_CONTROLS
} cpp0x_warn_str;
/* The various kinds of operation used by composite_pointer_type. */
"inline namespaces "
"only available with -std=c++0x or -std=gnu++0x");
break;
+ case CPP0X_OVERRIDE_CONTROLS:
+ pedwarn (input_location, 0,
+ "override controls (override/final) "
+ "only available with -std=c++0x or -std=gnu++0x");
+ break;
default:
gcc_unreachable();
}
if (token->type != CPP_NAME)
break;
if (!strcmp (IDENTIFIER_POINTER(token->u.value), "override"))
- virt_specifier = VIRT_SPEC_OVERRIDE;
+ {
+ maybe_warn_cpp0x (CPP0X_OVERRIDE_CONTROLS);
+ virt_specifier = VIRT_SPEC_OVERRIDE;
+ }
else if (!strcmp (IDENTIFIER_POINTER(token->u.value), "final"))
- virt_specifier = VIRT_SPEC_FINAL;
+ {
+ maybe_warn_cpp0x (CPP0X_OVERRIDE_CONTROLS);
+ virt_specifier = VIRT_SPEC_FINAL;
+ }
+ else if (!strcmp (IDENTIFIER_POINTER(token->u.value), "__final"))
+ {
+ virt_specifier = VIRT_SPEC_FINAL;
+ }
else
break;
+2011-07-22 Ville Voutilainen <ville.voutilainen@gmail.com>
+
+ * override1.C: This test should use c++0x mode.
+ * override3.C: New. Test the diagnostics in c++98 mode.
+
2011-07-22 Jason Merrill <jason@redhat.com>
Mark Glisse <marc.glisse@normalesup.org>
// { dg-do compile }
+// { dg-options "--std=c++0x" }
struct B
{
virtual void f() final {}
--- /dev/null
+// { dg-do compile }
+// { dg-options "--std=c++98" }
+
+struct B final {}; // { dg-warning "override controls" }
+
+struct D : B {}; // { dg-error "cannot derive from 'final' base" }
+
+struct E __final {};
+
+struct F : E {}; // { dg-error "cannot derive from 'final' base" }
+
+struct G
+{
+ virtual void f();
+};
+
+struct H : G
+{
+ void f() override; // { dg-warning "override controls" }
+};
+
+int main()
+{
+}