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
<< 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();
// 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}}
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 = {})