Anastasia created this revision. Herald added a subscriber: yaxunl. Fixing 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 particular common for OpenCL types to be declared implicitly in Clang to support the mode without standard header. https://reviews.llvm.org/D31397 Files: lib/Sema/SemaDecl.cpp test/SemaOpenCL/types.cl Index: test/SemaOpenCL/types.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/types.cl @@ -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; Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -2154,7 +2154,9 @@ // -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() || New->isImplicit() || + Context.getSourceManager().isInSystemHeader(Old->getLocation()) || Context.getSourceManager().isInSystemHeader(New->getLocation()))) return;
Index: test/SemaOpenCL/types.cl =================================================================== --- /dev/null +++ test/SemaOpenCL/types.cl @@ -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; Index: lib/Sema/SemaDecl.cpp =================================================================== --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -2154,7 +2154,9 @@ // -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() || New->isImplicit() || + Context.getSourceManager().isInSystemHeader(Old->getLocation()) || Context.getSourceManager().isInSystemHeader(New->getLocation()))) return;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits