Commit a59775a1 by Paolo Carlini Committed by Paolo Carlini

re PR c++/71099 (Misleading diagnostic message with 'virtual' used in…

re PR c++/71099 (Misleading diagnostic message with 'virtual' used in out-of-line definitions of class template member functions)

/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
parent 53d6d955
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
......
......@@ -12888,7 +12888,8 @@ cp_parser_function_specifier_opt (cp_parser* parser,
/* 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):
......
// 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" }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment