]> granicus.if.org Git - clang/commitdiff
Reverted OpenCL2.0 atomic type commits r231932, r231935
authorAnastasia Stulova <anastasia.stulova@arm.com>
Wed, 11 Mar 2015 17:26:37 +0000 (17:26 +0000)
committerAnastasia Stulova <anastasia.stulova@arm.com>
Wed, 11 Mar 2015 17:26:37 +0000 (17:26 +0000)
(caused undesirable update of -std flag to use _Atomic)

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

include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/TokenKinds.def
lib/Sema/Sema.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaType.cpp
test/Parser/opencl-atomics-cl20.cl [deleted file]
test/SemaCXX/atomic-type.cpp
test/SemaCXX/references.cpp

index a00a4db7ffa77cd95a9abc5f044783c2fdda6770..c7bf207b97e7f988c5927a6b8cd800a120a2ee8f 100644 (file)
@@ -7119,8 +7119,8 @@ def ext_c99_array_usage : Extension<
 def err_c99_array_usage_cxx : Error<
   "%select{qualifier in |static |}0array size %select{||'[*] '}0is a C99 "
   "feature, not permitted in C++">;
- def err_type_requires_extension : Error<
-  "use of type %0 requires %1 extension to be enabled">;
+def err_double_requires_fp64 : Error<
+  "use of type 'double' requires cl_khr_fp64 extension to be enabled">;
 def err_int128_unsupported : Error<
   "__int128 is not supported on this target">;
 def err_nsconsumed_attribute_mismatch : Error<
@@ -7297,8 +7297,6 @@ def err_opencl_return_value_with_address_space : Error<
   "return value cannot be qualified with address space">;
 def err_opencl_constant_no_init : Error<
   "variable in constant address space must be initialized">;
-def err_atomic_assignment : Error <
- "assigning directly to an atomic object is not allowed">;
 } // end of sema category
 
 let CategoryName = "OpenMP Issue" in {
index 0350f7a7cc367789a5c5b0fcdb077c127f3cb250..3319d4ed35e0252b87e0183f9d34167597a517d2 100644 (file)
@@ -270,7 +270,7 @@ KEYWORD(volatile                    , KEYALL)
 KEYWORD(while                       , KEYALL)
 KEYWORD(_Alignas                    , KEYALL)
 KEYWORD(_Alignof                    , KEYALL)
-KEYWORD(_Atomic                     , KEYC11|KEYCXX11|KEYNOMS)
+KEYWORD(_Atomic                     , KEYALL|KEYNOMS)
 KEYWORD(_Bool                       , KEYNOCXX)
 KEYWORD(_Complex                    , KEYALL)
 KEYWORD(_Generic                    , KEYALL)
index a1a9b9d0b8c155da29680f8b263aaf9e7d34cee7..a851ce145564a52544948253ac819cfdbe538864 100644 (file)
@@ -212,29 +212,6 @@ void Sema::Initialize() {
     addImplicitTypedef("image3d_t", Context.OCLImage3dTy);
     addImplicitTypedef("sampler_t", Context.OCLSamplerTy);
     addImplicitTypedef("event_t", Context.OCLEventTy);
-    if (getLangOpts().OpenCLVersion >= 200) {
-      addImplicitTypedef("atomic_int", Context.getAtomicType(Context.IntTy));
-      addImplicitTypedef("atomic_uint",
-                         Context.getAtomicType(Context.UnsignedIntTy));
-      addImplicitTypedef("atomic_long", Context.getAtomicType(Context.LongTy));
-      addImplicitTypedef("atomic_ulong",
-                         Context.getAtomicType(Context.UnsignedLongTy));
-      addImplicitTypedef("atomic_float",
-                         Context.getAtomicType(Context.FloatTy));
-      addImplicitTypedef("atomic_double",
-                         Context.getAtomicType(Context.DoubleTy));
-      // OpenCLC v2.0, s6.13.11.6 requires that atomic_flag is implemented as
-      // 32-bit integer and OpenCLC v2.0, s6.1.1 int is always 32-bit wide.
-      addImplicitTypedef("atomic_flag", Context.getAtomicType(Context.IntTy));
-      addImplicitTypedef("atomic_intptr_t",
-                         Context.getAtomicType(Context.getIntPtrType()));
-      addImplicitTypedef("atomic_uintptr_t",
-                         Context.getAtomicType(Context.getUIntPtrType()));
-      addImplicitTypedef("atomic_size_t",
-                         Context.getAtomicType(Context.getSizeType()));
-      addImplicitTypedef("atomic_ptrdiff_t",
-                         Context.getAtomicType(Context.getPointerDiffType()));
-    }
   }
 
   DeclarationName BuiltinVaList = &Context.Idents.get("__builtin_va_list");
index 9b0ccc9458ad7a271cdeb2942cf553c0e3cce2a4..a793d45da4e7df88709804774c4fb750cb1b57c7 100644 (file)
@@ -9747,19 +9747,6 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
       return ExprError();
   }
 
-  if (getLangOpts().OpenCL) {
-    // OpenCLC v2.0 s6.13.11.8 forbids operations on atomic types.
-    if (LHSExpr->getType()->isAtomicType() ||
-        RHSExpr->getType()->isAtomicType()) {
-      SourceRange SR(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
-      if (Opc == BO_Assign)
-        Diag(OpLoc, diag::err_atomic_assignment) << SR;
-      else
-        ResultTy = InvalidOperands(OpLoc, LHS, RHS);
-      return ExprError();
-    }
-  }
-
   switch (Opc) {
   case BO_Assign:
     ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, QualType());
@@ -10232,15 +10219,6 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
   ExprValueKind VK = VK_RValue;
   ExprObjectKind OK = OK_Ordinary;
   QualType resultType;
-  if (getLangOpts().OpenCL) {
-    // OpenCLC v2.0 s6.13.11.8, the only legal unary operation.
-    // for atomics is '&'.
-    if (Opc != UO_AddrOf && InputExpr->getType()->isAtomicType()) {
-      return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
-                       << InputExpr->getType()
-                       << Input.get()->getSourceRange());
-    }
-  }
   switch (Opc) {
   case UO_PreInc:
   case UO_PreDec:
index 03009b78b097f089f3d503bdab786a6948ee19ba..56142253a0886ac0477ea3aba4bc6b4006cc3f82 100644 (file)
@@ -871,8 +871,7 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
     if (S.getLangOpts().OpenCL &&
         !((S.getLangOpts().OpenCLVersion >= 120) ||
           S.getOpenCLOptions().cl_khr_fp64)) {
-      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
-          << Result << "cl_khr_fp64";
+      S.Diag(DS.getTypeSpecTypeLoc(), diag::err_double_requires_fp64);
       declarator.setInvalidType(true);
     }
     break;
@@ -948,30 +947,6 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
           << DS.getSourceRange();
         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 (!S.getOpenCLOptions().cl_khr_int64_base_atomics && !NoExtTypes) {
-          S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
-              << Result << "cl_khr_int64_base_atomics";
-          declarator.setInvalidType(true);
-        }
-        if (!S.getOpenCLOptions().cl_khr_int64_extended_atomics &&
-            !NoExtTypes) {
-          S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
-              << Result << "cl_khr_int64_extended_atomics";
-          declarator.setInvalidType(true);
-        }
-        if (!S.getOpenCLOptions().cl_khr_fp64 && BT &&
-            BT->getKind() == BuiltinType::Double) {
-          S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_requires_extension)
-              << Result << "cl_khr_fp64";
-          declarator.setInvalidType(true);
-        }
-      }
     }
 
     // TypeQuals handled by caller.
diff --git a/test/Parser/opencl-atomics-cl20.cl b/test/Parser/opencl-atomics-cl20.cl
deleted file mode 100644 (file)
index 9118bd2..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-// 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
-#pragma OPENCL EXTENSION cl_khr_int64_extended_atomics:enable
-#pragma OPENCL EXTENSION cl_khr_fp64:enable
-#endif
-
-void atomic_types_test() {
-// OpenCL v2.0 s6.13.11.6 defines supported atomic types.
-  atomic_int i;
-  atomic_uint ui;
-  atomic_long l;
-  atomic_ulong ul;
-  atomic_float f;
-  atomic_double d;
-  atomic_flag fl;
-  atomic_intptr_t ip;
-  atomic_uintptr_t uip;
-  atomic_size_t s;
-  atomic_ptrdiff_t pd;
-// OpenCL v2.0 s6.13.11.8, _Atomic type specifier and _Atomic type qualifier
-// are not supported by OpenCL.
-  _Atomic int i; // expected-error {{use of undeclared identifier '_Atomic'}}
-}
-#ifndef CL20
-// expected-error@-16 {{use of undeclared identifier 'atomic_int'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uint'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_long'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ulong'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_float'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_double'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_flag'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_intptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_uintptr_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_size_t'}}
-// expected-error@-16 {{use of undeclared identifier 'atomic_ptrdiff_t'}}
-#elif !EXT
-// expected-error@-26 {{use of type 'atomic_long' (aka '_Atomic(long)') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error@-27 {{use of type 'atomic_long' (aka '_Atomic(long)') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error@-27 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned long)') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error@-28 {{use of type 'atomic_ulong' (aka '_Atomic(unsigned long)') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error@-27 {{use of type 'atomic_double' (aka '_Atomic(double)') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error@-28 {{use of type 'atomic_double' (aka '_Atomic(double)') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error@-29 {{use of type 'atomic_double' (aka '_Atomic(double)') requires cl_khr_fp64 extension to be enabled}}
-// expected-error-re@-28 {{use of type 'atomic_intptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-29 {{use of type 'atomic_intptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-29 {{use of type 'atomic_uintptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-30 {{use of type 'atomic_uintptr_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-30 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-31 {{use of type 'atomic_size_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}}
-// expected-error-re@-31 {{use of type 'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_base_atomics extension to be enabled}}
-// expected-error-re@-32 {{use of type 'atomic_ptrdiff_t' (aka '_Atomic({{.+}})') requires cl_khr_int64_extended_atomics extension to be enabled}}
-#endif
-
-#ifdef CL20
-void foo(atomic_int * ptr) {}
-void atomic_ops_test() {
-  atomic_int i;
-  foo(&i);
-// OpenCL v2.0 s6.13.11.8, arithemtic operation are not permitted on atomic types.
-  i++; // expected-error {{invalid argument type 'atomic_int' (aka '_Atomic(int)') to unary expression}}
-  i = 1; // expected-error {{assigning directly to an atomic object is not allowed}}
-  i += 1; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'int')}}
-  i = i + i; // expected-error {{invalid operands to binary expression ('atomic_int' (aka '_Atomic(int)') and 'atomic_int')}}
-}
-#endif
index c1ddad4ad730ec26b3e11982902101018d347833..a2b314aacdd420c635f5bb1e9da22dee509d17b0 100644 (file)
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -verify -pedantic %s -std=c++98
 // RUN: %clang_cc1 -verify -pedantic %s -std=c++11
 
 template<typename T> struct atomic {
index b37863246c9efd85d0982978aa3d714e4de38228..b1768b1a3a4d80be7880992f131b4f4e5f65e405 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
 int g(int);
 
 void f() {