/cp
2016-05-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/71099
* parser.c (cp_parser_function_specifier_opt): Use current_class_type
to improve the diagnostic about wrong uses of 'virtual'.
/testsuite
2016-05-30 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/71099
* g++.dg/parse/virtual1.C: New.
From-SVN: r236885
+2016-05-30 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/71099
+ * parser.c (cp_parser_function_specifier_opt): Use current_class_type
+ to improve the diagnostic about wrong uses of 'virtual'.
+
2016-05-29 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/71105
/* 14.5.2.3 [temp.mem]
A member function template shall not be virtual. */
- if (PROCESSING_REAL_TEMPLATE_DECL_P ())
+ if (PROCESSING_REAL_TEMPLATE_DECL_P ()
+ && current_class_type)
error_at (token->location, "templates may not be %<virtual%>");
else
set_and_check_decl_spec_loc (decl_specs, ds_virtual, token);
+2016-05-30 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR c++/71099
+ * g++.dg/parse/virtual1.C: New.
+
2016-05-30 Uros Bizjak <ubizjak@gmail.com>
* gcc.target/i386/iamcu/args.h (clear_non_sret_int_hardware_registers):
--- /dev/null
+// PR c++/71099
+
+struct A {
+ virtual void foo();
+};
+
+virtual void A::foo() {} // { dg-error "'virtual' outside class" }
+
+template<typename>
+struct B {
+ virtual void foo();
+};
+
+template<typename T>
+virtual void B<T>::foo() {} // { dg-error "'virtual' outside class" }
+
+struct C {
+ template<typename>
+ virtual void foo(); // { dg-error "templates may not be 'virtual'" }
+};
+
+template<typename>
+virtual void C::foo() {} // { dg-error "'virtual' outside class" }
+
+template<typename>
+struct D {
+ template<typename>
+ virtual void foo(); // { dg-error "templates may not be 'virtual'" }
+};
+
+template<typename T>
+template<typename>
+virtual void D<T>::foo() {} // { dg-error "'virtual' outside class" }