]> granicus.if.org Git - clang/commitdiff
[OPENMP50]Do not emit warning for the function with the currently
authorAlexey Bataev <a.bataev@hotmail.com>
Mon, 30 Sep 2019 18:24:35 +0000 (18:24 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Mon, 30 Sep 2019 18:24:35 +0000 (18:24 +0000)
defined body.

If the function is currently defined, we should not emit a warning that
it might be emitted already because it was not really emitted.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373243 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOpenMP.cpp
test/OpenMP/declare_variant_messages.c
test/OpenMP/declare_variant_messages.cpp

index f2dc66e383ee03a1ec7f8abcb9766352aef63186..b3a2ed62a7cf0b4026b401502bea124358fae7e7 100644 (file)
@@ -4936,8 +4936,9 @@ Sema::checkOpenMPDeclareVariantFunction(Sema::DeclGroupPtrTy DG,
         << FD->getLocation();
 
   // Check if the function was emitted already.
-  if ((LangOpts.EmitAllDecls && FD->isDefined()) ||
-      Context.DeclMustBeEmitted(FD))
+  const FunctionDecl *Definition;
+  if (!FD->isThisDeclarationADefinition() && FD->isDefined(Definition) &&
+      (LangOpts.EmitAllDecls || Context.DeclMustBeEmitted(Definition)))
     Diag(SR.getBegin(), diag::warn_omp_declare_variant_after_emitted)
         << FD->getLocation();
 
index ce4956ae6fbf81f7b83357b908f779cb31871313..0eeaae052302282ea94e33ba6235e75a2e7fc729 100644 (file)
@@ -79,9 +79,13 @@ int bar() {
 // expected-warning@+1 {{'#pragma omp declare variant' cannot be applied for function after first usage; the original function might be used}}
 #pragma omp declare variant(after_use_variant) match(xxx={})
 int after_use(void);
-// expected-warning@+1 {{#pragma omp declare variant' cannot be applied to the function that was defined already; the original function might be used}}
 #pragma omp declare variant(after_use_variant) match(xxx={})
 int defined(void) { return 0; }
+int defined1(void) { return 0; }
+// expected-warning@+1 {{#pragma omp declare variant' cannot be applied to the function that was defined already; the original function might be used}}
+#pragma omp declare variant(after_use_variant) match(xxx={})
+int defined1(void);
+
 
 int diff_cc_variant(void);
 // expected-error@+1 {{function with '#pragma omp declare variant' has a different calling convention}}
index 0c322463a7f36e8e1289bc66234c2c292e592a67..ca61c53b0f6cdf64dfde50a6dd8cc11fe4e2536b 100644 (file)
@@ -172,10 +172,14 @@ auto fn_deduced_variant() { return 0; }
 int fn_deduced();
 
 int fn_deduced_variant1();
-// expected-warning@+1 {{'#pragma omp declare variant' cannot be applied to the function that was defined already; the original function might be used}}
 #pragma omp declare variant(fn_deduced_variant1) match(xxx = {})
 auto fn_deduced1() { return 0; }
 
+auto fn_deduced3() { return 0; }
+// expected-warning@+1 {{'#pragma omp declare variant' cannot be applied to the function that was defined already; the original function might be used}}
+#pragma omp declare variant(fn_deduced_variant1) match(xxx = {})
+auto fn_deduced3();
+
 auto fn_deduced_variant2() { return 0; }
 // expected-error@+1 {{variant in '#pragma omp declare variant' with type 'int ()' is incompatible with type 'float (*)()'}}
 #pragma omp declare variant(fn_deduced_variant2) match(xxx = {})