From a3e7a167c499bfe35628676137637c5265bb06aa Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Wed, 28 Nov 2018 21:54:04 +0000 Subject: Allow cpu-dispatch forward declarations. As a followup to r347805, allow forward declarations of cpu-dispatch and cpu-specific for the same reasons. Change-Id: Ic1bde9be369b1f8f1d47d58e6fbdc2f9dfcdd785 llvm-svn: 347812 --- clang/lib/Sema/SemaDecl.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'clang/lib/Sema/SemaDecl.cpp') diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 8ccd9ae322b..5b2d2899f81 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -9822,6 +9822,15 @@ static bool CheckMultiVersionAdditionalDecl( return true; } + // Permit forward declarations in the case where these two are compatible. + if (!OldFD->isMultiVersion()) { + OldFD->setIsMultiVersion(); + NewFD->setIsMultiVersion(); + Redeclaration = true; + OldDecl = OldFD; + return false; + } + NewFD->setIsMultiVersion(); Redeclaration = false; MergeTypeWithPrevious = false; @@ -9896,14 +9905,6 @@ static bool CheckMultiVersionFunction(Sema &S, FunctionDecl *NewFD, return CheckTargetCausesMultiVersioning(S, OldFD, NewFD, NewTA, Redeclaration, OldDecl, MergeTypeWithPrevious, Previous); - // Previous declarations lack CPUDispatch/CPUSpecific. - if (!OldFD->isMultiVersion()) { - S.Diag(OldFD->getLocation(), diag::err_multiversion_required_in_redecl) - << 1; - S.Diag(NewFD->getLocation(), diag::note_multiversioning_caused_here); - NewFD->setInvalidDecl(); - return true; - } // At this point, we have a multiversion function decl (in OldFD) AND an // appropriate attribute in the current function decl. Resolve that these are -- cgit v1.2.3