[PATCH] D16351: [FIX] Bug 25404 - Crash on typedef in OpenCL 2.0

Igor Chesnokov via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 30 01:20:05 PST 2016


ichesnokov set the repository for this revision to rL LLVM.
ichesnokov updated this revision to Diff 46470.
ichesnokov added a comment.

Removed unuseful patch code.


Repository:
  rL LLVM

http://reviews.llvm.org/D16351

Files:
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/implicit-typedef.cl

Index: test/SemaOpenCL/implicit-typedef.cl
===================================================================
--- test/SemaOpenCL/implicit-typedef.cl
+++ test/SemaOpenCL/implicit-typedef.cl
@@ -0,0 +1,2 @@
+// RUN: %clang_cc1 "-cc1" "-emit-llvm" "-D" "cl_khr_fp64" "-D" "cl_khr_int64_base_atomics" "-fno-dwarf-directory-asm" "-fmessage-length" "205" "-fdiagnostics-show-option" "-cl-std=CL2.0" "-x" "cl" "%s" "-fcolor-diagnostics" -o -
+typedef atomic_int atomic_flag;
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -2033,6 +2033,12 @@
   if (getLangOpts().Modules || getLangOpts().C11)
     return;
   
+  // Added isImplicit() check, because implicit TypeDecl::getLocation()
+  // returns 0. The're many implicit typedefs in OpenCL, e.g. atomic_flag.
+  if (Old->isImplicit() || New->isImplicit()) {
+    return;
+  }
+
   // If we have a redefinition of a typedef in C, emit a warning.  This warning
   // is normally mapped to an error, but can be controlled with
   // -Wtypedef-redefinition.  If either the original or the redefinition is


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16351.46470.patch
Type: text/x-patch
Size: 1153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160130/7f8d1bd5/attachment-0001.bin>


More information about the cfe-commits mailing list