From 43ab9a00eb165625e07c1bc92afcfb521e926b1d Mon Sep 17 00:00:00 2001 From: Anastasia Stulova Date: Thu, 12 May 2016 16:28:25 +0000 Subject: [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 llvm-svn: 269305 --- clang/lib/Parse/ParseDecl.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'clang/lib/Parse/ParseDecl.cpp') diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 1c93c08f718..91445281673 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -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(DeclSpec &DS, 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; } -- cgit v1.2.3