[OPENMP50]Emit warnings if the functions was defined/used before marked
declare variant.
We can use the original function if it was used/emitted already. So,
just use warnings for these cases, not errors.
llvm-svn: 373010
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 0403f11..17586c9 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4931,11 +4931,15 @@
}
// Allow #pragma omp declare variant only if the function is not used.
- if (FD->isUsed(false)) {
- Diag(SR.getBegin(), diag::err_omp_declare_variant_after_used)
+ if (FD->isUsed(false))
+ Diag(SR.getBegin(), diag::warn_omp_declare_variant_after_used)
<< FD->getLocation();
- return None;
- }
+
+ // Check if the function was emitted already.
+ if ((LangOpts.EmitAllDecls && FD->isDefined()) ||
+ Context.DeclMustBeEmitted(FD))
+ Diag(SR.getBegin(), diag::warn_omp_declare_variant_after_emitted)
+ << FD->getLocation();
// The VariantRef must point to function.
if (!VariantRef) {