diff --git a/clang/include/clang/Basic/DiagnosticParseKinds.td b/clang/include/clang/Basic/DiagnosticParseKinds.td --- a/clang/include/clang/Basic/DiagnosticParseKinds.td +++ b/clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1239,8 +1239,6 @@ "missing ':' after %0 - ignoring">, InGroup; def warn_pragma_expected_predicate : Warning< "expected %select{'enable', 'disable', 'begin' or 'end'|'disable'}0 - ignoring">, InGroup; -def warn_pragma_begin_end_mismatch : Warning< - "OpenCL extension end directive mismatches begin directive - ignoring">, InGroup; def warn_pragma_unknown_extension : Warning< "unknown OpenCL extension %0 - ignoring">, InGroup; def warn_pragma_unsupported_extension : Warning< diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -4372,8 +4372,6 @@ ShowInSystemHeader; def note_ovl_candidate_disabled_by_function_cond_attr : Note< "candidate disabled: %0">; -def note_ovl_candidate_disabled_by_extension : Note< - "candidate unavailable as it requires OpenCL extension '%0' to be enabled">; def err_addrof_function_disabled_by_enable_if_attr : Error< "cannot take address of function %0 because it has one or more " "non-tautological enable_if conditions">; diff --git a/clang/include/clang/Sema/Overload.h b/clang/include/clang/Sema/Overload.h --- a/clang/include/clang/Sema/Overload.h +++ b/clang/include/clang/Sema/Overload.h @@ -760,9 +760,6 @@ /// This candidate was not viable because its address could not be taken. ovl_fail_addr_not_available, - /// This candidate was not viable because its OpenCL extension is disabled. - ovl_fail_ext_disabled, - /// This inherited constructor is not viable because it would slice the /// argument. ovl_fail_inhctor_slice, diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -10142,73 +10142,6 @@ /// potentially-throwing. bool checkFinalSuspendNoThrow(const Stmt *FinalSuspend); - //===--------------------------------------------------------------------===// - // OpenCL extensions. - // -private: - std::string CurrOpenCLExtension; - /// Extensions required by an OpenCL type. - llvm::DenseMap> OpenCLTypeExtMap; - /// Extensions required by an OpenCL declaration. - llvm::DenseMap> OpenCLDeclExtMap; -public: - llvm::StringRef getCurrentOpenCLExtension() const { - return CurrOpenCLExtension; - } - - /// Check if a function declaration \p FD associates with any - /// extensions present in OpenCLDeclExtMap and if so return the - /// extension(s) name(s). - std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD); - - /// Check if a function type \p FT associates with any - /// extensions present in OpenCLTypeExtMap and if so return the - /// extension(s) name(s). - std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT); - - /// Find an extension in an appropriate extension map and return its name - template - std::string getOpenCLExtensionsFromExtMap(T* FT, MapT &Map); - - void setCurrentOpenCLExtension(llvm::StringRef Ext) { - CurrOpenCLExtension = std::string(Ext); - } - - /// Set OpenCL extensions for a type which can only be used when these - /// OpenCL extensions are enabled. If \p Exts is empty, do nothing. - /// \param Exts A space separated list of OpenCL extensions. - void setOpenCLExtensionForType(QualType T, llvm::StringRef Exts); - - /// Set OpenCL extensions for a declaration which can only be - /// used when these OpenCL extensions are enabled. If \p Exts is empty, do - /// nothing. - /// \param Exts A space separated list of OpenCL extensions. - void setOpenCLExtensionForDecl(Decl *FD, llvm::StringRef Exts); - - /// Set current OpenCL extensions for a type which can only be used - /// when these OpenCL extensions are enabled. If current OpenCL extension is - /// empty, do nothing. - void setCurrentOpenCLExtensionForType(QualType T); - - /// Set current OpenCL extensions for a declaration which - /// can only be used when these OpenCL extensions are enabled. If current - /// OpenCL extension is empty, do nothing. - void setCurrentOpenCLExtensionForDecl(Decl *FD); - - bool isOpenCLDisabledDecl(Decl *FD); - - /// Check if type \p T corresponding to declaration specifier \p DS - /// is disabled due to required OpenCL extensions being disabled. If so, - /// emit diagnostics. - /// \return true if type is disabled. - bool checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType T); - - /// Check if declaration \p D used by expression \p E - /// is disabled due to required OpenCL extensions being disabled. If so, - /// emit diagnostics. - /// \return true if type is disabled. - bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E); - //===--------------------------------------------------------------------===// // OpenMP directives and clauses. // @@ -10262,21 +10195,6 @@ /// Pop OpenMP function region for non-capturing function. void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI); - /// Checks if a type or a declaration is disabled due to the owning extension - /// being disabled, and emits diagnostic messages if it is disabled. - /// \param D type or declaration to be checked. - /// \param DiagLoc source location for the diagnostic message. - /// \param DiagInfo information to be emitted for the diagnostic message. - /// \param SrcRange source range of the declaration. - /// \param Map maps type or declaration to the extensions. - /// \param Selector selects diagnostic message: 0 for type and 1 for - /// declaration. - /// \return true if the type or declaration is disabled. - template - bool checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc, DiagInfoT DiagInfo, - MapT &Map, unsigned Selector = 0, - SourceRange SrcRange = SourceRange()); - /// Helper to keep information about the current `omp begin/end declare /// variant` nesting. struct OMPDeclareVariantScope { diff --git a/clang/include/clang/Serialization/ASTWriter.h b/clang/include/clang/Serialization/ASTWriter.h --- a/clang/include/clang/Serialization/ASTWriter.h +++ b/clang/include/clang/Serialization/ASTWriter.h @@ -510,8 +510,6 @@ void WriteDeclContextVisibleUpdate(const DeclContext *DC); void WriteFPPragmaOptions(const FPOptionsOverride &Opts); void WriteOpenCLExtensions(Sema &SemaRef); - void WriteOpenCLExtensionTypes(Sema &SemaRef); - void WriteOpenCLExtensionDecls(Sema &SemaRef); void WriteCUDAPragmas(Sema &SemaRef); void WriteObjCCategories(); void WriteLateParsedTemplates(Sema &SemaRef); diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp --- a/clang/lib/Parse/ParsePragma.cpp +++ b/clang/lib/Parse/ParsePragma.cpp @@ -792,11 +792,9 @@ // Therefore, it should never be added by default. Opt.acceptsPragma(Name); } - Actions.setCurrentOpenCLExtension(Name); } else if (State == End) { - if (Name != Actions.getCurrentOpenCLExtension()) - PP.Diag(NameLoc, diag::warn_pragma_begin_end_mismatch); - Actions.setCurrentOpenCLExtension(""); + // There is no behavior for this directive. We only accept this for + // backward compatibility. } else if (!Opt.isKnown(Name) || !Opt.isWithPragma(Name)) PP.Diag(NameLoc, diag::warn_pragma_unknown_extension) << Ident; else if (Opt.isSupportedExtension(Name, getLangOpts())) diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -1081,8 +1081,6 @@ Decl *TheDecl = Actions.ParsedFreeStandingDeclSpec(getCurScope(), AS_none, DS, AnonRecord); DS.complete(TheDecl); - if (getLangOpts().OpenCL) - Actions.setCurrentOpenCLExtensionForDecl(TheDecl); if (AnonRecord) { Decl* decls[] = {AnonRecord, TheDecl}; return Actions.BuildDeclaratorGroup(decls); diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -369,7 +369,6 @@ #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) { \ addImplicitTypedef(#ExtType, Context.Id##Ty); \ - setOpenCLExtensionForType(Context.Id##Ty, #Ext); \ } #include "clang/Basic/OpenCLExtensionTypes.def" } @@ -2467,115 +2466,3 @@ Sema::getMismatchingDeleteExpressions() const { return DeleteExprs; } - -void Sema::setOpenCLExtensionForType(QualType T, llvm::StringRef ExtStr) { - if (ExtStr.empty()) - return; - llvm::SmallVector Exts; - ExtStr.split(Exts, " ", /* limit */ -1, /* keep empty */ false); - auto CanT = T.getCanonicalType().getTypePtr(); - for (auto &I : Exts) - OpenCLTypeExtMap[CanT].insert(I.str()); -} - -void Sema::setOpenCLExtensionForDecl(Decl *FD, StringRef ExtStr) { - llvm::SmallVector Exts; - ExtStr.split(Exts, " ", /* limit */ -1, /* keep empty */ false); - if (Exts.empty()) - return; - for (auto &I : Exts) - OpenCLDeclExtMap[FD].insert(I.str()); -} - -void Sema::setCurrentOpenCLExtensionForType(QualType T) { - if (CurrOpenCLExtension.empty()) - return; - setOpenCLExtensionForType(T, CurrOpenCLExtension); -} - -void Sema::setCurrentOpenCLExtensionForDecl(Decl *D) { - if (CurrOpenCLExtension.empty()) - return; - setOpenCLExtensionForDecl(D, CurrOpenCLExtension); -} - -std::string Sema::getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD) { - if (!OpenCLDeclExtMap.empty()) - return getOpenCLExtensionsFromExtMap(FD, OpenCLDeclExtMap); - - return ""; -} - -std::string Sema::getOpenCLExtensionsFromTypeExtMap(FunctionType *FT) { - if (!OpenCLTypeExtMap.empty()) - return getOpenCLExtensionsFromExtMap(FT, OpenCLTypeExtMap); - - return ""; -} - -template -std::string Sema::getOpenCLExtensionsFromExtMap(T *FDT, MapT &Map) { - auto Loc = Map.find(FDT); - return llvm::join(Loc->second, " "); -} - -bool Sema::isOpenCLDisabledDecl(Decl *FD) { - auto Loc = OpenCLDeclExtMap.find(FD); - if (Loc == OpenCLDeclExtMap.end()) - return false; - for (auto &I : Loc->second) { - if (!getOpenCLOptions().isAvailableOption(I, getLangOpts())) - return true; - } - return false; -} - -template -bool Sema::checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc, - DiagInfoT DiagInfo, MapT &Map, - unsigned Selector, - SourceRange SrcRange) { - auto Loc = Map.find(D); - if (Loc == Map.end()) - return false; - bool Disabled = false; - for (auto &I : Loc->second) { - if (I != CurrOpenCLExtension && - !getOpenCLOptions().isAvailableOption(I, getLangOpts())) { - Diag(DiagLoc, diag::err_opencl_requires_extension) << Selector << DiagInfo - << I << SrcRange; - Disabled = true; - } - } - return Disabled; -} - -bool Sema::checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType QT) { - // Check extensions for declared types. - Decl *Decl = nullptr; - if (auto TypedefT = dyn_cast(QT.getTypePtr())) - Decl = TypedefT->getDecl(); - if (auto TagT = dyn_cast(QT.getCanonicalType().getTypePtr())) - Decl = TagT->getDecl(); - auto Loc = DS.getTypeSpecTypeLoc(); - - // Check extensions for vector types. - // e.g. double4 is not allowed when cl_khr_fp64 is absent. - if (QT->isExtVectorType()) { - auto TypePtr = QT->castAs()->getElementType().getTypePtr(); - return checkOpenCLDisabledTypeOrDecl(TypePtr, Loc, QT, OpenCLTypeExtMap); - } - - if (checkOpenCLDisabledTypeOrDecl(Decl, Loc, QT, OpenCLDeclExtMap)) - return true; - - // Check extensions for builtin types. - return checkOpenCLDisabledTypeOrDecl(QT.getCanonicalType().getTypePtr(), Loc, - QT, OpenCLTypeExtMap); -} - -bool Sema::checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E) { - IdentifierInfo *FnName = D.getIdentifier(); - return checkOpenCLDisabledTypeOrDecl(&D, E.getBeginLoc(), FnName, - OpenCLDeclExtMap, 1, D.getSourceRange()); -} diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -5579,9 +5579,6 @@ Dcl && Dcl->getDeclContext()->isFileContext()) Dcl->setTopLevelDeclInObjCContainer(); - if (getLangOpts().OpenCL) - setCurrentOpenCLExtensionForDecl(Dcl); - return Dcl; } diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -6488,9 +6488,6 @@ FD, /*Complain=*/true, Fn->getBeginLoc())) return ExprError(); - if (getLangOpts().OpenCL && checkOpenCLDisabledDecl(*FD, *Fn)) - return ExprError(); - checkDirectCallValidity(*this, Fn, FD, ArgExprs); } diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -6482,12 +6482,6 @@ Candidate.DeductionFailure.Data = FailedAttr; return; } - - if (LangOpts.OpenCL && isOpenCLDisabledDecl(Function)) { - Candidate.Viable = false; - Candidate.FailureKind = ovl_fail_ext_disabled; - return; - } } ObjCMethodDecl * @@ -11092,14 +11086,6 @@ << (ES.getExpr() ? ES.getExpr()->getSourceRange() : SourceRange()); } -static void DiagnoseOpenCLExtensionDisabled(Sema &S, OverloadCandidate *Cand) { - FunctionDecl *Callee = Cand->Function; - - S.Diag(Callee->getLocation(), - diag::note_ovl_candidate_disabled_by_extension) - << S.getOpenCLExtensionsFromDeclExtMap(Callee); -} - /// Generates a 'note' diagnostic for an overload candidate. We've /// already generated a primary error at the call site. /// @@ -11195,9 +11181,6 @@ case ovl_fail_explicit: return DiagnoseFailedExplicitSpec(S, Cand); - case ovl_fail_ext_disabled: - return DiagnoseOpenCLExtensionDisabled(S, Cand); - case ovl_fail_inhctor_slice: // It's generally not interesting to note copy/move constructors here. if (cast(Fn)->isCopyOrMoveConstructor()) diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1727,10 +1727,6 @@ declarator.setInvalidType(); } - if (S.getLangOpts().OpenCL && - S.checkOpenCLDisabledTypeDeclSpec(DS, Result)) - declarator.setInvalidType(true); - bool IsFixedPointType = DS.getTypeSpecType() == DeclSpec::TST_accum || DS.getTypeSpecType() == DeclSpec::TST_fract; diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -3635,30 +3635,6 @@ } break; - case OPENCL_EXTENSION_TYPES: - for (unsigned I = 0, E = Record.size(); I != E;) { - auto TypeID = static_cast<::TypeID>(Record[I++]); - auto *Type = GetType(TypeID).getTypePtr(); - auto NumExt = static_cast(Record[I++]); - for (unsigned II = 0; II != NumExt; ++II) { - auto Ext = ReadString(Record, I); - OpenCLTypeExtMap[Type].insert(Ext); - } - } - break; - - case OPENCL_EXTENSION_DECLS: - for (unsigned I = 0, E = Record.size(); I != E;) { - auto DeclID = static_cast<::DeclID>(Record[I++]); - auto *Decl = GetDecl(DeclID); - auto NumExt = static_cast(Record[I++]); - for (unsigned II = 0; II != NumExt; ++II) { - auto Ext = ReadString(Record, I); - OpenCLDeclExtMap[Decl].insert(Ext); - } - } - break; - case TENTATIVE_DEFINITIONS: for (unsigned I = 0, N = Record.size(); I != N; ++I) TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I])); @@ -7894,8 +7870,6 @@ } SemaObj->OpenCLFeatures = OpenCLExtensions; - SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap; - SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap; UpdateSema(); } diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -3965,72 +3965,6 @@ } Stream.EmitRecord(OPENCL_EXTENSIONS, Record); } - -void ASTWriter::WriteOpenCLExtensionTypes(Sema &SemaRef) { - if (!SemaRef.Context.getLangOpts().OpenCL) - return; - - // Sort the elements of the map OpenCLTypeExtMap by TypeIDs, - // without copying them. - const llvm::DenseMap> &OpenCLTypeExtMap = - SemaRef.OpenCLTypeExtMap; - using ElementTy = std::pair *>; - llvm::SmallVector StableOpenCLTypeExtMap; - StableOpenCLTypeExtMap.reserve(OpenCLTypeExtMap.size()); - - for (const auto &I : OpenCLTypeExtMap) - StableOpenCLTypeExtMap.emplace_back( - getTypeID(I.first->getCanonicalTypeInternal()), &I.second); - - auto CompareByTypeID = [](const ElementTy &E1, const ElementTy &E2) -> bool { - return E1.first < E2.first; - }; - llvm::sort(StableOpenCLTypeExtMap, CompareByTypeID); - - RecordData Record; - for (const ElementTy &E : StableOpenCLTypeExtMap) { - Record.push_back(E.first); // TypeID - const std::set *ExtSet = E.second; - Record.push_back(static_cast(ExtSet->size())); - for (const std::string &Ext : *ExtSet) - AddString(Ext, Record); - } - - Stream.EmitRecord(OPENCL_EXTENSION_TYPES, Record); -} - -void ASTWriter::WriteOpenCLExtensionDecls(Sema &SemaRef) { - if (!SemaRef.Context.getLangOpts().OpenCL) - return; - - // Sort the elements of the map OpenCLDeclExtMap by DeclIDs, - // without copying them. - const llvm::DenseMap> &OpenCLDeclExtMap = - SemaRef.OpenCLDeclExtMap; - using ElementTy = std::pair *>; - llvm::SmallVector StableOpenCLDeclExtMap; - StableOpenCLDeclExtMap.reserve(OpenCLDeclExtMap.size()); - - for (const auto &I : OpenCLDeclExtMap) - StableOpenCLDeclExtMap.emplace_back(getDeclID(I.first), &I.second); - - auto CompareByDeclID = [](const ElementTy &E1, const ElementTy &E2) -> bool { - return E1.first < E2.first; - }; - llvm::sort(StableOpenCLDeclExtMap, CompareByDeclID); - - RecordData Record; - for (const ElementTy &E : StableOpenCLDeclExtMap) { - Record.push_back(E.first); // DeclID - const std::set *ExtSet = E.second; - Record.push_back(static_cast(ExtSet->size())); - for (const std::string &Ext : *ExtSet) - AddString(Ext, Record); - } - - Stream.EmitRecord(OPENCL_EXTENSION_DECLS, Record); -} - void ASTWriter::WriteCUDAPragmas(Sema &SemaRef) { if (SemaRef.ForceCUDAHostDeviceDepth > 0) { RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth}; @@ -4775,17 +4709,12 @@ WriteIdentifierTable(PP, SemaRef.IdResolver, isModule); WriteFPPragmaOptions(SemaRef.CurFPFeatureOverrides()); WriteOpenCLExtensions(SemaRef); - WriteOpenCLExtensionTypes(SemaRef); WriteCUDAPragmas(SemaRef); // If we're emitting a module, write out the submodule information. if (WritingModule) WriteSubmodules(WritingModule); - // We need to have information about submodules to correctly deserialize - // decls from OpenCLExtensionDecls block - WriteOpenCLExtensionDecls(SemaRef); - Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes); // Write the record containing external, unnamed definitions. diff --git a/clang/test/CodeGenOpenCL/extension-begin.cl b/clang/test/CodeGenOpenCL/extension-begin.cl deleted file mode 100644 --- a/clang/test/CodeGenOpenCL/extension-begin.cl +++ /dev/null @@ -1,25 +0,0 @@ -// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -o - | FileCheck %s - -__attribute__((overloadable)) void f(int x); - -#pragma OPENCL EXTENSION my_ext : begin - -__attribute__((overloadable)) void f(long x); - -#pragma OPENCL EXTENSION my_ext : end - -#pragma OPENCL EXTENSION my_ext : enable - -//CHECK: define{{.*}} spir_func void @test_f1(i64 %x) -//CHECK: call spir_func void @_Z1fl(i64 %{{.*}}) -void test_f1(long x) { - f(x); -} - -#pragma OPENCL EXTENSION my_ext : disable - -//CHECK: define{{.*}} spir_func void @test_f2(i64 %x) -//CHECK: call spir_func void @_Z1fi(i32 %{{.*}}) -void test_f2(long x) { - f(x); -} diff --git a/clang/test/SemaOpenCL/extension-begin.h b/clang/test/SemaOpenCL/extension-begin.h --- a/clang/test/SemaOpenCL/extension-begin.h +++ b/clang/test/SemaOpenCL/extension-begin.h @@ -5,10 +5,13 @@ #pragma OPENCL EXTENSION all : end #pragma OPENCL EXTENSION my_ext : begin - struct A { int a; }; +#pragma OPENCL EXTENSION my_ext : end +#pragma OPENCL EXTENSION my_ext : end + +#define my_ext typedef struct A TypedefOfA; typedef const __private TypedefOfA* PointerOfA; @@ -17,10 +20,8 @@ __attribute__((overloadable)) void g(long x); -#pragma OPENCL EXTENSION my_ext : end -#pragma OPENCL EXTENSION my_ext : end + __attribute__((overloadable)) void g(void); #endif // INCLUDED - diff --git a/clang/test/SemaOpenCL/extension-begin.cl b/clang/test/SemaOpenCL/extension-begin.cl --- a/clang/test/SemaOpenCL/extension-begin.cl +++ b/clang/test/SemaOpenCL/extension-begin.cl @@ -29,25 +29,23 @@ #ifndef USE_PCH // expected-warning@extension-begin.h:4 {{expected 'disable' - ignoring}} // expected-warning@extension-begin.h:5 {{expected 'disable' - ignoring}} -// expected-warning@extension-begin.h:21 {{OpenCL extension end directive mismatches begin directive - ignoring}} #endif // USE_PCH +#if defined(IMPLICIT_INCLUDE) && defined(USE_PCH) +//expected-no-diagnostics +#endif + +// Tests that the pragmas are accepted for backward compatibility. #pragma OPENCL EXTENSION my_ext : enable -void test_f1(void) { +#pragma OPENCL EXTENSION my_ext : disable + +#ifndef my_ext +#error "Missing my_ext macro" +#endif + +// When extension is supported its functionality can be used freely. +void test(void) { struct A test_A1; f(); g(0); } - -#pragma OPENCL EXTENSION my_ext : disable -void test_f2(void) { - struct A test_A2; // expected-error {{use of type 'struct A' requires my_ext support}} - const struct A test_A_local; // expected-error {{use of type 'struct A' requires my_ext support}} - TypedefOfA test_typedef_A; // expected-error {{use of type 'TypedefOfA' (aka 'struct A') requires my_ext support}} - PointerOfA test_A_pointer; // expected-error {{use of type 'PointerOfA' (aka 'const __private struct A *') requires my_ext support}} - f(); // expected-error {{use of declaration 'f' requires my_ext support}} - g(0); // expected-error {{no matching function for call to 'g'}} - // expected-note@extension-begin.h:18 {{candidate unavailable as it requires OpenCL extension 'my_ext' to be enabled}} - // expected-note@extension-begin.h:23 {{candidate function not viable: requires 0 arguments, but 1 was provided}} -} -