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,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;