r248891 - [OpenCL 2.0] Fix wrong atomic type detection in the diagnostics of allowed types
Anastasia Stulova via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 30 04:48:16 PDT 2015
Author: stulova
Date: Wed Sep 30 06:48:15 2015
New Revision: 248891
URL: http://llvm.org/viewvc/llvm-project?rev=248891&view=rev
Log:
[OpenCL 2.0] Fix wrong atomic type detection in the diagnostics of allowed types
Modified:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Parser/opencl-atomics-cl20.cl
Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=248891&r1=248890&r2=248891&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Wed Sep 30 06:48:15 2015
@@ -1390,11 +1390,13 @@ static QualType ConvertDeclSpecToType(Ty
if (Result.isNull()) {
declarator.setInvalidType(true);
} else if (S.getLangOpts().OpenCL) {
- if (const AtomicType *AT = Result->getAs<AtomicType>()) {
- const BuiltinType *BT = AT->getValueType()->getAs<BuiltinType>();
- bool NoExtTypes = BT && (BT->getKind() == BuiltinType::Int ||
- BT->getKind() == BuiltinType::UInt ||
- BT->getKind() == BuiltinType::Float);
+ if (Result->getAs<AtomicType>()) {
+ StringRef TypeName = Result.getBaseTypeIdentifier()->getName();
+ bool NoExtTypes =
+ llvm::StringSwitch<bool>(TypeName)
+ .Cases("atomic_int", "atomic_uint", "atomic_float",
+ "atomic_flag", true)
+ .Default(false);
if (!S.getOpenCLOptions().cl_khr_int64_base_atomics && !NoExtTypes) {
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
<< Result << "cl_khr_int64_base_atomics";
@@ -1406,8 +1408,8 @@ static QualType ConvertDeclSpecToType(Ty
<< Result << "cl_khr_int64_extended_atomics";
declarator.setInvalidType(true);
}
- if (!S.getOpenCLOptions().cl_khr_fp64 && BT &&
- BT->getKind() == BuiltinType::Double) {
+ if (!S.getOpenCLOptions().cl_khr_fp64 &&
+ !TypeName.compare("atomic_double")) {
S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
<< Result << "cl_khr_fp64";
declarator.setInvalidType(true);
Modified: cfe/trunk/test/Parser/opencl-atomics-cl20.cl
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/opencl-atomics-cl20.cl?rev=248891&r1=248890&r2=248891&view=diff
==============================================================================
--- cfe/trunk/test/Parser/opencl-atomics-cl20.cl (original)
+++ cfe/trunk/test/Parser/opencl-atomics-cl20.cl Wed Sep 30 06:48:15 2015
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -verify -pedantic -fsyntax-only
-// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20
-// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT
+// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DCL20
+// RUN: %clang_cc1 %s -verify -fsyntax-only -cl-std=CL2.0 -DCL20 -DEXT
#ifdef EXT
#pragma OPENCL EXTENSION cl_khr_int64_base_atomics:enable
More information about the cfe-commits
mailing list