r269305 - [OpenCL] Output OpenCL version in diagnostics.
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Thu May 12 09:28:26 PDT 2016
Author: stulova
Date: Thu May 12 11:28:25 2016
New Revision: 269305
URL: http://llvm.org/viewvc/llvm-project?rev=269305&view=rev
Log:
[OpenCL] Output OpenCL version in diagnostics.
Diagnostics should note version dependent issues by giving
a hint about current version being compiled for.
This patch changes diagnostics of static storage class specifier
and generic type qualifier to specify OpenCL version as well as
converts other diagnostics to match the style.
Patch by Vedran Miletic!
Review: http://reviews.llvm.org/D19780
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/test/Parser/opencl-cl20.cl
cfe/trunk/test/Parser/opencl-storage-class.cl
cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
cfe/trunk/test/SemaOpenCL/storageclass.cl
Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=269305&r1=269304&r2=269305&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May 12 11:28:25 2016
@@ -7865,13 +7865,13 @@ def err_opencl_builtin_pipe_invalid_acce
def err_opencl_invalid_access_qualifier : Error<
"access qualifier can only be used for pipe and image type">;
def err_opencl_invalid_read_write : Error<
- "access qualifier %0 can not be used for %1 %select{|earlier than OpenCL2.0 version}2">;
+ "access qualifier %0 can not be used for %1 %select{|earlier than OpenCL version 2.0}2">;
def err_opencl_multiple_access_qualifiers : Error<
"multiple access qualifiers">;
// OpenCL Section 6.8.g
def err_opencl_unknown_type_specifier : Error<
- "OpenCL does not support the '%0' %select{type qualifier|storage class specifier}1">;
+ "OpenCL version %0 does not support the '%1' %select{type qualifier|storage class specifier}2">;
// OpenCL v2.0 s6.12.5 Blocks restrictions
def err_opencl_block_storage_type : Error<
Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=269305&r1=269304&r2=269305&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Thu May 12 11:28:25 2016
@@ -28,6 +28,7 @@
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/ScopedPrinter.h"
using namespace clang;
@@ -3514,9 +3515,13 @@ void Parser::ParseDeclarationSpecifiers(
if (DiagID == diag::ext_duplicate_declspec)
Diag(Tok, DiagID)
<< PrevSpec << FixItHint::CreateRemoval(Tok.getLocation());
- else if (DiagID == diag::err_opencl_unknown_type_specifier)
- Diag(Tok, DiagID) << PrevSpec << isStorageClass;
- else
+ else if (DiagID == diag::err_opencl_unknown_type_specifier) {
+ const int OpenCLVer = getLangOpts().OpenCLVersion;
+ std::string VerSpec = llvm::to_string(OpenCLVer / 100) +
+ std::string (".") +
+ llvm::to_string((OpenCLVer % 100) / 10);
+ Diag(Tok, DiagID) << VerSpec << PrevSpec << isStorageClass;
+ } else
Diag(Tok, DiagID) << PrevSpec;
}
Modified: cfe/trunk/test/Parser/opencl-cl20.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-cl20.cl?rev=269305&r1=269304&r2=269305&view=diff
==============================================================================
--- cfe/trunk/test/Parser/opencl-cl20.cl (original)
+++ cfe/trunk/test/Parser/opencl-cl20.cl Thu May 12 11:28:25 2016
@@ -10,9 +10,9 @@ __generic int * __generic_test(__generic
return var;
}
#ifndef CL20
-// expected-error at -5 {{OpenCL does not support the '__generic' type qualifier}}
-// expected-error at -6 {{OpenCL does not support the '__generic' type qualifier}}
-// expected-error at -6 {{OpenCL does not support the '__generic' type qualifier}}
+// expected-error at -5 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
+// expected-error at -6 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
+// expected-error at -6 {{OpenCL version 1.0 does not support the '__generic' type qualifier}}
#endif
generic int * generic_test(generic int *arg) {
@@ -20,7 +20,7 @@ generic int * generic_test(generic int *
return var;
}
#ifndef CL20
-// expected-error at -5 {{OpenCL does not support the 'generic' type qualifier}}
-// expected-error at -6 {{OpenCL does not support the 'generic' type qualifier}}
-// expected-error at -6 {{OpenCL does not support the 'generic' type qualifier}}
+// expected-error at -5 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
+// expected-error at -6 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
+// expected-error at -6 {{OpenCL version 1.0 does not support the 'generic' type qualifier}}
#endif
Modified: cfe/trunk/test/Parser/opencl-storage-class.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-storage-class.cl?rev=269305&r1=269304&r2=269305&view=diff
==============================================================================
--- cfe/trunk/test/Parser/opencl-storage-class.cl (original)
+++ cfe/trunk/test/Parser/opencl-storage-class.cl Thu May 12 11:28:25 2016
@@ -2,10 +2,10 @@
void test_storage_class_specs()
{
- static int a; // expected-error {{OpenCL does not support the 'static' storage class specifier}}
- register int b; // expected-error {{OpenCL does not support the 'register' storage class specifier}}
- extern int c; // expected-error {{OpenCL does not support the 'extern' storage class specifier}}
- auto int d; // expected-error {{OpenCL does not support the 'auto' storage class specifier}}
+ static int a; // expected-error {{OpenCL version 1.0 does not support the 'static' storage class specifier}}
+ register int b; // expected-error {{OpenCL version 1.0 does not support the 'register' storage class specifier}}
+ extern int c; // expected-error {{OpenCL version 1.0 does not support the 'extern' storage class specifier}}
+ auto int d; // expected-error {{OpenCL version 1.0 does not support the 'auto' storage class specifier}}
#pragma OPENCL EXTENSION cl_clang_storage_class_specifiers : enable
static int e; // expected-error {{static local variable must reside in constant address space}}
Modified: cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl?rev=269305&r1=269304&r2=269305&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-access-qualifier.cl Thu May 12 11:28:25 2016
@@ -10,5 +10,5 @@ void test3(read_only read_only image1d_t
#ifdef CL20
void test4(read_write pipe int i){} // expected-error{{access qualifier 'read_write' can not be used for 'pipe int'}}
#else
-void test4(__read_write image1d_t i) {} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL2.0 version}}
+void test4(__read_write image1d_t i) {} // expected-error{{access qualifier '__read_write' can not be used for '__read_write image1d_t' earlier than OpenCL version 2.0}}
#endif
Modified: cfe/trunk/test/SemaOpenCL/storageclass.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/storageclass.cl?rev=269305&r1=269304&r2=269305&view=diff
==============================================================================
--- cfe/trunk/test/SemaOpenCL/storageclass.cl (original)
+++ cfe/trunk/test/SemaOpenCL/storageclass.cl Thu May 12 11:28:25 2016
@@ -13,7 +13,7 @@ void kernel foo() {
constant int L1 = 0;
local int L2;
- auto int L3 = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}}
+ auto int L3 = 7; // expected-error{{OpenCL version 1.2 does not support the 'auto' storage class specifier}}
global int L4; // expected-error{{function scope variable cannot be declared in global address space}}
}
More information about the cfe-commits
mailing list