From 39691fddaf4f5199ecf9960ae3059943d59f659b Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Wed, 4 Oct 2017 01:58:22 +0000 Subject: [PATCH] We allow implicit function declarations as an extension in all C dialects. Remove OpenCL special case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314872 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/DiagnosticSemaKinds.td | 4 +--- lib/Sema/SemaDecl.cpp | 8 +++----- test/SemaOpenCL/clang-builtin-version.cl | 2 +- test/SemaOpenCL/to_addr_builtin.cl | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/clang/Basic/DiagnosticSemaKinds.td b/include/clang/Basic/DiagnosticSemaKinds.td index 0c491cc60d..df5d7473ec 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.td +++ b/include/clang/Basic/DiagnosticSemaKinds.td @@ -355,7 +355,7 @@ def warn_implicit_function_decl : Warning< "implicit declaration of function %0">, InGroup, DefaultIgnore; def ext_implicit_function_decl : ExtWarn< - "implicit declaration of function %0 is invalid in C99">, + "implicit declaration of function %0 is invalid in %select{C99|OpenCL}1">, InGroup; def note_function_suggestion : Note<"did you mean %0?">; @@ -8449,8 +8449,6 @@ def err_opencl_scalar_type_rank_greater_than_vector_type : Error< "element. (%0 and %1)">; def err_bad_kernel_param_type : Error< "%0 cannot be used as the type of a kernel parameter">; -def err_opencl_implicit_function_decl : Error< - "implicit declaration of function %0 is invalid in OpenCL">; def err_record_with_pointers_kernel_param : Error< "%select{struct|union}0 kernel parameters may not contain pointers">; def note_within_field_of_type : Note< diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 06009b1756..7f3f811002 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -12642,17 +12642,15 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc, } // Extension in C99. Legal in C90, but warn about it. + // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported. unsigned diag_id; if (II.getName().startswith("__builtin_")) diag_id = diag::warn_builtin_unknown; - // OpenCL v2.0 s6.9.u - Implicit function declaration is not supported. - else if (getLangOpts().OpenCL) - diag_id = diag::err_opencl_implicit_function_decl; - else if (getLangOpts().C99) + else if (getLangOpts().C99 || getLangOpts().OpenCL) diag_id = diag::ext_implicit_function_decl; else diag_id = diag::warn_implicit_function_decl; - Diag(Loc, diag_id) << &II; + Diag(Loc, diag_id) << &II << getLangOpts().OpenCL; // If we found a prior declaration of this function, don't bother building // another one. We've already pushed that one into scope, so there's nothing diff --git a/test/SemaOpenCL/clang-builtin-version.cl b/test/SemaOpenCL/clang-builtin-version.cl index 3e270e64c6..270345d86a 100644 --- a/test/SemaOpenCL/clang-builtin-version.cl +++ b/test/SemaOpenCL/clang-builtin-version.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 100 +// RUN: %clang_cc1 %s -fblocks -verify -pedantic-errors -fsyntax-only -ferror-limit 100 // Confirm CL2.0 Clang builtins are not available in earlier versions diff --git a/test/SemaOpenCL/to_addr_builtin.cl b/test/SemaOpenCL/to_addr_builtin.cl index 56db4abed5..70956f007a 100644 --- a/test/SemaOpenCL/to_addr_builtin.cl +++ b/test/SemaOpenCL/to_addr_builtin.cl @@ -10,7 +10,7 @@ void test(void) { glob = to_global(glob, loc); #if __OPENCL_C_VERSION__ < CL_VERSION_2_0 - // expected-error@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}} + // expected-warning@-2{{implicit declaration of function 'to_global' is invalid in OpenCL}} // expected-warning@-3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}} #else // expected-error@-5{{invalid number of arguments to function: 'to_global'}} -- 2.40.0