r342885 - Revert "We allow implicit function declarations as an extension in all C dialects. Remove OpenCL special case."

Anastasia Stulova via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 24 07:21:57 PDT 2018


Author: stulova
Date: Mon Sep 24 07:21:56 2018
New Revision: 342885

URL: http://llvm.org/viewvc/llvm-project?rev=342885&view=rev
Log:
Revert "We allow implicit function declarations as an extension in all C dialects. Remove OpenCL special case."

Discussed on cfe-commits (Week-of-Mon-20180820), this change leads to
the generation of invalid IR for OpenCL without giving an error.
Therefore, the conclusion was to revert.


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaDecl.cpp
    cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl
    cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=342885&r1=342884&r2=342885&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Sep 24 07:21:56 2018
@@ -369,7 +369,7 @@ def warn_implicit_function_decl : Warnin
   "implicit declaration of function %0">,
   InGroup<ImplicitFunctionDeclare>, DefaultIgnore;
 def ext_implicit_function_decl : ExtWarn<
-  "implicit declaration of function %0 is invalid in %select{C99|OpenCL}1">,
+  "implicit declaration of function %0 is invalid in C99">,
   InGroup<ImplicitFunctionDeclare>;
 def note_function_suggestion : Note<"did you mean %0?">;
 
@@ -8556,6 +8556,8 @@ def err_opencl_scalar_type_rank_greater_
     "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<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=342885&r1=342884&r2=342885&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Sep 24 07:21:56 2018
@@ -13360,15 +13360,17 @@ NamedDecl *Sema::ImplicitlyDefineFunctio
   }
 
   // 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;
-  else if (getLangOpts().C99 || getLangOpts().OpenCL)
+  // 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)
     diag_id = diag::ext_implicit_function_decl;
   else
     diag_id = diag::warn_implicit_function_decl;
-  Diag(Loc, diag_id) << &II << getLangOpts().OpenCL;
+  Diag(Loc, diag_id) << &II;
 
   // 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

Modified: cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl?rev=342885&r1=342884&r2=342885&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl (original)
+++ cfe/trunk/test/SemaOpenCL/clang-builtin-version.cl Mon Sep 24 07:21:56 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -fblocks -verify -pedantic-errors -fsyntax-only -ferror-limit 100
+// RUN: %clang_cc1 %s -fblocks -verify -pedantic -fsyntax-only -ferror-limit 100
 
 // Confirm CL2.0 Clang builtins are not available in earlier versions
 

Modified: cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl?rev=342885&r1=342884&r2=342885&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl (original)
+++ cfe/trunk/test/SemaOpenCL/to_addr_builtin.cl Mon Sep 24 07:21:56 2018
@@ -10,7 +10,7 @@ void test(void) {
 
   glob = to_global(glob, loc);
 #if __OPENCL_C_VERSION__ < CL_VERSION_2_0
-  // expected-warning at -2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
+  // expected-error at -2{{implicit declaration of function 'to_global' is invalid in OpenCL}}
   // expected-warning at -3{{incompatible integer to pointer conversion assigning to '__global int *' from 'int'}}
 #else
   // expected-error at -5{{invalid number of arguments to function: 'to_global'}}




More information about the cfe-commits mailing list