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 Index: test/SemaOpenCL/implicit-typedef.cl =================================================================== --- test/SemaOpenCL/implicit-typedef.cl +++ test/SemaOpenCL/implicit-typedef.cl @@ -0,0 +1,3 @@ +// RUN: %clang_cc1 -main-file-name opencl_math.cl -cl-std=CL2.0 -fsyntax-only -x cl %s +// expected-no-diagnostics +typedef atomic_int atomic_flag;