Author: stulova Date: Tue Apr 4 11:50:46 2017 New Revision: 299447 URL: http://llvm.org/viewvc/llvm-project?rev=299447&view=rev Log: [Bug 25404] Fix crash on typedef in OpenCL 2.0
Fixed the assertion due to absence of source location for implicitly defined types (using addImplicitTypedef()). During Sema checks the source location is being expected and therefore an assertion is triggered. The change is not specific to OpenCL. But it is particularly common for OpenCL types to be declared implicitly in Clang to support the mode without the standard header. Differential Revision: https://reviews.llvm.org/D31397 Added: cfe/trunk/test/SemaOpenCL/types.cl Modified: cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=299447&r1=299446&r2=299447&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Apr 4 11:50:46 2017 @@ -2154,7 +2154,9 @@ void Sema::MergeTypedefNameDecl(Scope *S // -Wtypedef-redefinition. If either the original or the redefinition is // in a system header, don't emit this for compatibility with GCC. if (getDiagnostics().getSuppressSystemWarnings() && - (Context.getSourceManager().isInSystemHeader(Old->getLocation()) || + // Some standard types are defined implicitly in Clang (e.g. OpenCL). + (Old->isImplicit() || + Context.getSourceManager().isInSystemHeader(Old->getLocation()) || Context.getSourceManager().isInSystemHeader(New->getLocation()))) return; Added: cfe/trunk/test/SemaOpenCL/types.cl URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/types.cl?rev=299447&view=auto ============================================================================== --- cfe/trunk/test/SemaOpenCL/types.cl (added) +++ cfe/trunk/test/SemaOpenCL/types.cl Tue Apr 4 11:50:46 2017 @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only + +// expected-no-diagnostics + +// Check redefinition of standard types +typedef atomic_int atomic_flag; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits