[PATCH] D34871: [OpenCL] Add function name to extension diagnostic

Joey Gouly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 30 01:49:10 PDT 2017


joey created this revision.
Herald added subscribers: Anastasia, yaxunl.

Slightly improve the diagnostic by including the function name.

This has been separated out from https://reviews.llvm.org/D33945.


https://reviews.llvm.org/D34871

Files:
  Sema/Sema.cpp
  SemaOpenCL/extension-begin.cl
  clang/Basic/DiagnosticSemaKinds.td
  clang/Sema/Sema.h


Index: SemaOpenCL/extension-begin.cl
===================================================================
--- SemaOpenCL/extension-begin.cl
+++ SemaOpenCL/extension-begin.cl
@@ -46,7 +46,7 @@
   const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext extension to be enabled}}
   TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext extension to be enabled}}
   PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const struct A *') requires my_ext extension to be enabled}}
-  f(); // expected-error {{use of declaration requires my_ext extension to be enabled}}
+  f(); // expected-error {{use of declaration 'f' requires my_ext extension to be enabled}}
   g(0); // expected-error {{no matching function for call to 'g'}}
         // expected-note at -26 {{candidate disabled due to OpenCL extension}}
         // expected-note at -22 {{candidate function not viable: requires 0 arguments, but 1 was provided}}
Index: Sema/Sema.cpp
===================================================================
--- Sema/Sema.cpp
+++ Sema/Sema.cpp
@@ -1688,7 +1688,8 @@
                                        QT, OpenCLTypeExtMap);
 }
 
-bool Sema::checkOpenCLDisabledDecl(const Decl &D, const Expr &E) {
-  return checkOpenCLDisabledTypeOrDecl(&D, E.getLocStart(), "",
+bool Sema::checkOpenCLDisabledDecl(const FunctionDecl &D, const Expr &E) {
+  IdentifierInfo *FnName = D.getIdentifier();
+  return checkOpenCLDisabledTypeOrDecl(&D, E.getLocStart(), FnName,
                                        OpenCLDeclExtMap, 1, D.getSourceRange());
 }
Index: clang/Sema/Sema.h
===================================================================
--- clang/Sema/Sema.h
+++ clang/Sema/Sema.h
@@ -8432,7 +8432,7 @@
   /// is disabled due to required OpenCL extensions being disabled. If so,
   /// emit diagnostics.
   /// \return true if type is disabled.
-  bool checkOpenCLDisabledDecl(const Decl &D, const Expr &E);
+  bool checkOpenCLDisabledDecl(const FunctionDecl &D, const Expr &E);
 
   //===--------------------------------------------------------------------===//
   // OpenMP directives and clauses.
Index: clang/Basic/DiagnosticSemaKinds.td
===================================================================
--- clang/Basic/DiagnosticSemaKinds.td
+++ clang/Basic/DiagnosticSemaKinds.td
@@ -8404,7 +8404,7 @@
 def err_opencl_variadic_function : Error<
   "invalid prototype, variadic arguments are not allowed in OpenCL">;
 def err_opencl_requires_extension : Error<
-  "use of %select{type |declaration}0%1 requires %2 extension to be enabled">;
+  "use of %select{type|declaration}0 %1 requires %2 extension to be enabled">;
 
 // OpenCL v2.0 s6.13.6 -- Builtin Pipe Functions
 def err_opencl_builtin_pipe_first_arg : Error<


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34871.104660.patch
Type: text/x-patch
Size: 2826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170630/fa24e073/attachment.bin>


More information about the cfe-commits mailing list