diff mbox

Fix PR c++/18969 (invalid return statement diagnosed too late)

Message ID CA+C-WL__qEBQrH+ZFK1Nij1FiLvCCbnzTFevL3h_W4+8eTxWpw@mail.gmail.com
State New
Headers show

Commit Message

Patrick Palka July 26, 2015, 5:50 p.m. UTC
On Sun, Jul 26, 2015 at 1:09 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> Committed with this additional change to fix a latent testcase bug:
>
> diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload.C
> b/gcc/testsuite/g++.old-deja/g++.jason/overload.C
> index 6a747ff..28b029f 100644
> --- a/gcc/testsuite/g++.old-deja/g++.jason/overload.C
> +++ b/gcc/testsuite/g++.old-deja/g++.jason/overload.C
> @@ -5,7 +5,7 @@ enum bar {};
>  void operator+ (int, int);// { dg-error "" } .*
>  void operator+ (bar&, int);
>
> -template <class T> void operator+ (int b, T& t) { return b; }
> +template <class T> void operator+ (int b, T& t) { return; }
>  void operator+ (int, bar&);
>
>  template <class T> class foo

Hmm, on second thought, I don't think this fix is right.  It may be
the case that the 'return b;' was there to make instantiation of that
template a compile-time error. By changing it to 'return;'
instantiation is allowed.  Is this property important here?  Should I
preserve the original property (that instantiation is a compile-time
error) by instead doing the following?

    Adjust g++.old-deja/g++.jason/overload.C

    gcc/testsuite/ChangeLog:

        * g++.old-deja/g++.jason/overload.C: Adjust to preserve original
        property that instantiation is a compile-time error.

Comments

Jason Merrill Aug. 20, 2015, 10:42 p.m. UTC | #1
On 07/26/2015 01:50 PM, Patrick Palka wrote:
> Hmm, on second thought, I don't think this fix is right.  It may be
> the case that the 'return b;' was there to make instantiation of that
> template a compile-time error. By changing it to 'return;'
> instantiation is allowed.  Is this property important here?  Should I
> preserve the original property (that instantiation is a compile-time
> error) by instead doing the following?

Sure, can't hurt.

Jason
diff mbox

Patch

diff --git a/gcc/testsuite/g++.old-deja/g++.jason/overload.C
b/gcc/testsuite/g++.old-deja/g++.jason/overload.C
index 28b029f..5d27713 100644
--- a/gcc/testsuite/g++.old-deja/g++.jason/overload.C
+++ b/gcc/testsuite/g++.old-deja/g++.jason/overload.C
@@ -5,7 +5,7 @@  enum bar {};
 void operator+ (int, int);// { dg-error "" } .*
 void operator+ (bar&, int);

-template <class T> void operator+ (int b, T& t) { return; }
+template <class T> void operator+ (int b, T& t) { (void) T::bogus; }
 void operator+ (int, bar&);

 template <class T> class foo