From 0c799f39e52a62a6096d20d209d07b36f260752d Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Fri, 10 Dec 2021 15:31:22 +0100 Subject: [PATCH 1/2] [class.virtual] Explicit object member functions cannot be virtual including when overriding a virtual function. Remove a prohibition focusing on 'declared virtual' from [dcl.fct]. --- source/classes.tex | 15 +++++++++++++++ source/declarations.tex | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/source/classes.tex b/source/classes.tex index 59c0cedd8b..c909c9db43 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -3870,6 +3870,21 @@ \end{codeblock} \end{example} +\pnum +A virtual function shall not be an explicit object member +function\iref{dcl.fct}. +\begin{example} +\begin{codeblock} +struct B { + virtual void g(); // \#1 +}; +struct D : B { + virtual void f(this D&); // error: explicit object member function cannot be virtual + void g(this D&); // overrides \#1; error: explicit object member function cannot be virtual +}; +\end{codeblock} +\end{example} + \pnum The \grammarterm{ref-qualifier}, or lack thereof, of an overriding function shall be the same as that of the overridden function. diff --git a/source/declarations.tex b/source/declarations.tex index 02fcaaa862..15ffd3e743 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -3579,7 +3579,7 @@ A \grammarterm{member-declarator} with an explicit-object-parameter-declaration shall not include a \grammarterm{ref-qualifier} or a \grammarterm{cv-qualifier-seq} and -shall not be declared \keyword{static} or \keyword{virtual}. +shall not be declared \keyword{static}. \begin{example} \begin{codeblock} struct C { From 836b952d30dcea6ef22a36857399aec139638b87 Mon Sep 17 00:00:00 2001 From: Jens Maurer Date: Sat, 11 Dec 2021 23:27:45 +0100 Subject: [PATCH 2/2] [class.free] Prohibit explicit object parameter for allocation and deallocation functions --- source/classes.tex | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/classes.tex b/source/classes.tex index c909c9db43..3c77482153 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -2991,6 +2991,10 @@ \end{codeblock} \end{note} +\pnum +An allocation or deallocation function for a class +shall not have an explicit object parameter\iref{dcl.fct}. + \pnum Access to the deallocation function is checked statically, even if a different one is actually executed.