@@ -3922,18 +3922,6 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S,
39223922 }
39233923
39243924 if (getLangOpts().CPlusPlus) {
3925- // C++1z [over.load]p2
3926- // Certain function declarations cannot be overloaded:
3927- // -- Function declarations that differ only in the return type,
3928- // the exception specification, or both cannot be overloaded.
3929-
3930- // Check the exception specifications match. This may recompute the type of
3931- // both Old and New if it resolved exception specifications, so grab the
3932- // types again after this. Because this updates the type, we do this before
3933- // any of the other checks below, which may update the "de facto" NewQType
3934- // but do not necessarily update the type of New.
3935- if (CheckEquivalentExceptionSpec(Old, New))
3936- return true;
39373925 OldQType = Context.getCanonicalType(Old->getType());
39383926 NewQType = Context.getCanonicalType(New->getType());
39393927
@@ -4055,6 +4043,19 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S,
40554043 }
40564044 }
40574045
4046+ // C++1z [over.load]p2
4047+ // Certain function declarations cannot be overloaded:
4048+ // -- Function declarations that differ only in the return type,
4049+ // the exception specification, or both cannot be overloaded.
4050+
4051+ // Check the exception specifications match. This may recompute the type of
4052+ // both Old and New if it resolved exception specifications, so grab the
4053+ // types again after this. Because this updates the type, we do this before
4054+ // any of the other checks below, which may update the "de facto" NewQType
4055+ // but do not necessarily update the type of New.
4056+ if (CheckEquivalentExceptionSpec(Old, New))
4057+ return true;
4058+
40584059 // C++11 [dcl.attr.noreturn]p1:
40594060 // The first declaration of a function shall specify the noreturn
40604061 // attribute if any declaration of that function specifies the noreturn
0 commit comments