The proper fix for this is attached. It was too unsafe to rely on the target 
type mapping, since for each architecture types are mapped differently. In this 
case for 32 bit archs ptr types are mapped to normal int, therefore the check 
didn't work correctly. So I am now just using the type names instead of 
checking created type. 

This implementation doesn't rely on any target information and therefore should 
work similarly for all architectures now. Just tested for x86 and hexagon and 
it worked.

If it's ok, I can commit the fix now.

I am adding Pekka here as the original reviewer of this patch.

Thanks for help!
Anastasia

-----Original Message-----
From: Renato Golin [mailto:[email protected]] 
Sent: 18 March 2015 16:19
To: NAKAMURA Takumi
Cc: Anastasia Stulova; cfe-commits
Subject: Re: r232631 - OpenCL: CL2.0 atomic types

On 18 March 2015 at 15:40, Renato Golin <[email protected]> wrote:
> Thanks, it was also failing on ARM. I'll check if your fix also worked 
> there when it passes.

It did. Cheers!

--renato
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index 669cb9a..6985b7f 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -949,11 +949,13 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
&state) {
         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";
@@ -965,8 +967,8 @@ static QualType ConvertDeclSpecToType(TypeProcessingState 
&state) {
               << 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);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to