]> granicus.if.org Git - clang/commitdiff
[OpenCL] Add function name to extension diagnostic
authorJoey Gouly <joey.gouly@gmail.com>
Fri, 30 Jun 2017 14:23:01 +0000 (14:23 +0000)
committerJoey Gouly <joey.gouly@gmail.com>
Fri, 30 Jun 2017 14:23:01 +0000 (14:23 +0000)
Slightly improve the diagnostic by including the function name.

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

include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Sema/Sema.h
lib/Sema/Sema.cpp
test/SemaOpenCL/extension-begin.cl

index 7b1671bb8777be5b2f14eca849fa37fe5c0eb076..136e48ab5e547fdd5a2def61d6da914d2605cea8 100644 (file)
@@ -8410,7 +8410,7 @@ def warn_opencl_attr_deprecated_ignored : Warning <
 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<
index 8dee74eb2a123f917cc5fd4f279ffb81554ff5fa..75ff5fdb37a1d0e771bc21c46b3270a772ee09db 100644 (file)
@@ -8432,7 +8432,7 @@ public:
   /// 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 NamedDecl &D, const Expr &E);
 
   //===--------------------------------------------------------------------===//
   // OpenMP directives and clauses.
index 007a5e483e6cee92774e67c2119efae8ad411211..34f5e26be81042b3e78bec468c6f1bb647010414 100644 (file)
@@ -1688,7 +1688,8 @@ bool Sema::checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType QT) {
                                        QT, OpenCLTypeExtMap);
 }
 
-bool Sema::checkOpenCLDisabledDecl(const Decl &D, const Expr &E) {
-  return checkOpenCLDisabledTypeOrDecl(&D, E.getLocStart(), "",
+bool Sema::checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E) {
+  IdentifierInfo *FnName = D.getIdentifier();
+  return checkOpenCLDisabledTypeOrDecl(&D, E.getLocStart(), FnName,
                                        OpenCLDeclExtMap, 1, D.getSourceRange());
 }
index 3393458a893a4b076afc49069ecf4c281895737b..92ea8814323329e49249927d52c58a8d7f8a32cb 100644 (file)
@@ -46,7 +46,7 @@ void test_f2(void) {
   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@-26 {{candidate disabled due to OpenCL extension}}
         // expected-note@-22 {{candidate function not viable: requires 0 arguments, but 1 was provided}}