[PATCH] D25480: __builtin_fpclassify missing one int parameter
This revision was automatically updated to reflect the committed changes. Closed by commit rL284277: __builtin_fpclassify missing one int parameter (authored by davidsh). Changed prior to commit: https://reviews.llvm.org/D25480?vs=74377=74740#toc Repository: rL LLVM https://reviews.llvm.org/D25480 Files: cfe/trunk/include/clang/Basic/Builtins.def cfe/trunk/test/Sema/builtin-unary-fp.c Index: cfe/trunk/include/clang/Basic/Builtins.def === --- cfe/trunk/include/clang/Basic/Builtins.def +++ cfe/trunk/include/clang/Basic/Builtins.def @@ -367,7 +367,7 @@ BUILTIN(__builtin_isunordered , "i.", "Fnc") // Unary FP classification -BUILTIN(__builtin_fpclassify, "i.", "Fnc") +BUILTIN(__builtin_fpclassify, "ii.", "Fnc") BUILTIN(__builtin_isfinite, "i.", "Fnc") BUILTIN(__builtin_isinf, "i.", "Fnc") BUILTIN(__builtin_isinf_sign, "i.", "Fnc") Index: cfe/trunk/test/Sema/builtin-unary-fp.c === --- cfe/trunk/test/Sema/builtin-unary-fp.c +++ cfe/trunk/test/Sema/builtin-unary-fp.c @@ -11,6 +11,7 @@ check(__builtin_isnan(1,2)); // expected-error{{too many arguments}} check(__builtin_fpclassify(0, 0, 0, 0, 0, 1.0)); check(__builtin_fpclassify(0, 0, 0, 0, 0, 1)); // expected-error{{requires argument of floating point type}} + check(__builtin_fpclassify(0, 1, 2, 3, 4.5, 5.0)); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 4.5 to 4}} check(__builtin_fpclassify(0, 0, 0, 0, 1)); // expected-error{{too few arguments}} check(__builtin_fpclassify(0, 0, 0, 0, 0, 1, 0)); // expected-error{{too many arguments}} } Index: cfe/trunk/include/clang/Basic/Builtins.def === --- cfe/trunk/include/clang/Basic/Builtins.def +++ cfe/trunk/include/clang/Basic/Builtins.def @@ -367,7 +367,7 @@ BUILTIN(__builtin_isunordered , "i.", "Fnc") // Unary FP classification -BUILTIN(__builtin_fpclassify, "i.", "Fnc") +BUILTIN(__builtin_fpclassify, "ii.", "Fnc") BUILTIN(__builtin_isfinite, "i.", "Fnc") BUILTIN(__builtin_isinf, "i.", "Fnc") BUILTIN(__builtin_isinf_sign, "i.", "Fnc") Index: cfe/trunk/test/Sema/builtin-unary-fp.c === --- cfe/trunk/test/Sema/builtin-unary-fp.c +++ cfe/trunk/test/Sema/builtin-unary-fp.c @@ -11,6 +11,7 @@ check(__builtin_isnan(1,2)); // expected-error{{too many arguments}} check(__builtin_fpclassify(0, 0, 0, 0, 0, 1.0)); check(__builtin_fpclassify(0, 0, 0, 0, 0, 1)); // expected-error{{requires argument of floating point type}} + check(__builtin_fpclassify(0, 1, 2, 3, 4.5, 5.0)); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 4.5 to 4}} check(__builtin_fpclassify(0, 0, 0, 0, 1)); // expected-error{{too few arguments}} check(__builtin_fpclassify(0, 0, 0, 0, 0, 1, 0)); // expected-error{{too many arguments}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r284277 - __builtin_fpclassify missing one int parameter
Author: davidsh Date: Fri Oct 14 15:43:37 2016 New Revision: 284277 URL: http://llvm.org/viewvc/llvm-project?rev=284277=rev Log: __builtin_fpclassify missing one int parameter Patch by Tania Albarghouthi. Differential Revision: https://reviews.llvm.org/D25480 Modified: cfe/trunk/include/clang/Basic/Builtins.def cfe/trunk/test/Sema/builtin-unary-fp.c Modified: cfe/trunk/include/clang/Basic/Builtins.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=284277=284276=284277=diff == --- cfe/trunk/include/clang/Basic/Builtins.def (original) +++ cfe/trunk/include/clang/Basic/Builtins.def Fri Oct 14 15:43:37 2016 @@ -367,7 +367,7 @@ BUILTIN(__builtin_islessgreater , "i.", BUILTIN(__builtin_isunordered , "i.", "Fnc") // Unary FP classification -BUILTIN(__builtin_fpclassify, "i.", "Fnc") +BUILTIN(__builtin_fpclassify, "ii.", "Fnc") BUILTIN(__builtin_isfinite, "i.", "Fnc") BUILTIN(__builtin_isinf, "i.", "Fnc") BUILTIN(__builtin_isinf_sign, "i.", "Fnc") Modified: cfe/trunk/test/Sema/builtin-unary-fp.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtin-unary-fp.c?rev=284277=284276=284277=diff == --- cfe/trunk/test/Sema/builtin-unary-fp.c (original) +++ cfe/trunk/test/Sema/builtin-unary-fp.c Fri Oct 14 15:43:37 2016 @@ -11,6 +11,7 @@ void a() { check(__builtin_isnan(1,2)); // expected-error{{too many arguments}} check(__builtin_fpclassify(0, 0, 0, 0, 0, 1.0)); check(__builtin_fpclassify(0, 0, 0, 0, 0, 1)); // expected-error{{requires argument of floating point type}} + check(__builtin_fpclassify(0, 1, 2, 3, 4.5, 5.0)); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 4.5 to 4}} check(__builtin_fpclassify(0, 0, 0, 0, 1)); // expected-error{{too few arguments}} check(__builtin_fpclassify(0, 0, 0, 0, 0, 1, 0)); // expected-error{{too many arguments}} } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r283460 - [OpenMP] Check if the template specialization is mappable instead of specialized template Differential Revision: https://reviews.llvm.org/D25252
Author: davidsh Date: Thu Oct 6 10:47:36 2016 New Revision: 283460 URL: http://llvm.org/viewvc/llvm-project?rev=283460=rev Log: [OpenMP] Check if the template specialization is mappable instead of specialized template Differential Revision: https://reviews.llvm.org/D25252 Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/target_map_messages.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=283460=283459=283460=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Thu Oct 6 10:47:36 2016 @@ -10523,9 +10523,6 @@ static bool IsCXXRecordForMappable(Sema if (!RD || RD->isInvalidDecl()) return true; - if (auto *CTSD = dyn_cast(RD)) -if (auto *CTD = CTSD->getSpecializedTemplate()) - RD = CTD->getTemplatedDecl(); auto QTy = SemaRef.Context.getRecordType(RD); if (RD->isDynamicClass()) { SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy; Modified: cfe/trunk/test/OpenMP/target_map_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_map_messages.cpp?rev=283460=283459=283460=diff == --- cfe/trunk/test/OpenMP/target_map_messages.cpp (original) +++ cfe/trunk/test/OpenMP/target_map_messages.cpp Thu Oct 6 10:47:36 2016 @@ -347,6 +347,15 @@ public: S5(int v):a(v) { } }; +template +struct S6; + +template<> +struct S6 // expected-note {{mappable type cannot be polymorphic}} +{ + virtual void foo(); +}; + S3 h; #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} @@ -451,6 +460,7 @@ int main(int argc, char **argv) { int i; int = i; int *k = + S6 m; int x; int y; int to, tofrom, always; @@ -513,6 +523,8 @@ int main(int argc, char **argv) { {} #pragma omp target firstprivate(j) map(j) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as firstprivate}} {} +#pragma omp target map(m) // expected-error {{type 'S6' is not mappable to target}} + {} return tmain(argc)+tmain (argc); // expected-note {{in instantiation of function template specialization 'tmain ' requested here}} expected-note {{in instantiation of function template specialization 'tmain ' requested here}} } #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25252: [OpenMP] Check if the template specialization is mappable instead of specialized template
davidsh created this revision. davidsh added reviewers: carlo.bertolli, arpith-jacob, kkwli0, sfantao, ABataev. davidsh added a subscriber: cfe-commits. Clang segfaults on this case instead of diagnosing because it looks at the specialized template: template struct MyClass; template<> struct MyClass { virtual void foo() {} }; int main() { MyClass m; #pragma omp target map(m) {} } https://reviews.llvm.org/D25252 Files: lib/Sema/SemaOpenMP.cpp test/OpenMP/target_map_messages.cpp Index: test/OpenMP/target_map_messages.cpp === --- test/OpenMP/target_map_messages.cpp +++ test/OpenMP/target_map_messages.cpp @@ -347,6 +347,15 @@ S5(int v):a(v) { } }; +template +struct S6; + +template<> +struct S6 // expected-note {{mappable type cannot be polymorphic}} +{ + virtual void foo(); +}; + S3 h; #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} @@ -451,6 +460,7 @@ int i; int = i; int *k = + S6 m; int x; int y; int to, tofrom, always; @@ -513,6 +523,8 @@ {} #pragma omp target firstprivate(j) map(j) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as firstprivate}} {} +#pragma omp target map(m) // expected-error {{type 'S6' is not mappable to target}} + {} return tmain(argc)+tmain (argc); // expected-note {{in instantiation of function template specialization 'tmain ' requested here}} expected-note {{in instantiation of function template specialization 'tmain ' requested here}} } #endif Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -10523,9 +10523,6 @@ if (!RD || RD->isInvalidDecl()) return true; - if (auto *CTSD = dyn_cast(RD)) -if (auto *CTD = CTSD->getSpecializedTemplate()) - RD = CTD->getTemplatedDecl(); auto QTy = SemaRef.Context.getRecordType(RD); if (RD->isDynamicClass()) { SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy; Index: test/OpenMP/target_map_messages.cpp === --- test/OpenMP/target_map_messages.cpp +++ test/OpenMP/target_map_messages.cpp @@ -347,6 +347,15 @@ S5(int v):a(v) { } }; +template +struct S6; + +template<> +struct S6 // expected-note {{mappable type cannot be polymorphic}} +{ + virtual void foo(); +}; + S3 h; #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} @@ -451,6 +460,7 @@ int i; int = i; int *k = + S6 m; int x; int y; int to, tofrom, always; @@ -513,6 +523,8 @@ {} #pragma omp target firstprivate(j) map(j) // expected-error {{firstprivate variable cannot be in a map clause in '#pragma omp target' directive}} expected-note {{defined as firstprivate}} {} +#pragma omp target map(m) // expected-error {{type 'S6' is not mappable to target}} + {} return tmain (argc)+tmain (argc); // expected-note {{in instantiation of function template specialization 'tmain ' requested here}} expected-note {{in instantiation of function template specialization 'tmain ' requested here}} } #endif Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -10523,9 +10523,6 @@ if (!RD || RD->isInvalidDecl()) return true; - if (auto *CTSD = dyn_cast(RD)) -if (auto *CTD = CTSD->getSpecializedTemplate()) - RD = CTD->getTemplatedDecl(); auto QTy = SemaRef.Context.getRecordType(RD); if (RD->isDynamicClass()) { SemaRef.Diag(Loc, diag::err_omp_not_mappable_type) << QTy; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24615: [OpenMP] clang doesnt diagnose if there is a lexical block around a for stmt for OpenMP loops. It is technically not allowed in the OpenMP standard
davidsh updated this revision to Diff 73520. davidsh added a comment. Adding a parameter to IgnoreContainers instead of copying the logic. https://reviews.llvm.org/D24615 Files: include/clang/AST/Stmt.h lib/AST/Stmt.cpp lib/Sema/SemaOpenMP.cpp test/OpenMP/for_loop_messages.cpp Index: test/OpenMP/for_loop_messages.cpp === --- test/OpenMP/for_loop_messages.cpp +++ test/OpenMP/for_loop_messages.cpp @@ -353,6 +353,14 @@ } #pragma omp parallel +// expected-error@+2 {{statement after '#pragma omp for' must be a for loop}} +#pragma omp for + { + for (int i = 0; i < 16; ++i) +; + } + +#pragma omp parallel // expected-note@+3 {{loop step is expected to be positive due to this condition}} // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} #pragma omp for Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -5133,7 +5133,8 @@ llvm::MapVector Captures; SmallVectorIterSpaces; IterSpaces.resize(NestedLoopCount); - Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true); + Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true, + /* IgnoreCompound */ false); for (unsigned Cnt = 0; Cnt < NestedLoopCount; ++Cnt) { if (CheckOpenMPIterationSpace(DKind, CurStmt, SemaRef, DSA, Cnt, NestedLoopCount, CollapseLoopCountExpr, Index: lib/AST/Stmt.cpp === --- lib/AST/Stmt.cpp +++ lib/AST/Stmt.cpp @@ -111,20 +111,24 @@ return s; } -/// \brief Skip no-op (attributed, compound) container stmts and skip captured -/// stmt at the top, if \a IgnoreCaptured is true. -Stmt *Stmt::IgnoreContainers(bool IgnoreCaptured) { +/// \brief Skip no-op (attributed, compound if \a IgnoreCompound is true) +/// container stmts and skip captured stmt at the top, if \a IgnoreCaptured +/// is true. +Stmt *Stmt::IgnoreContainers(bool IgnoreCaptured, bool IgnoreCompound) { Stmt *S = this; if (IgnoreCaptured) if (auto CapS = dyn_cast_or_null(S)) S = CapS->getCapturedStmt(); while (true) { if (auto AS = dyn_cast_or_null(S)) S = AS->getSubStmt(); -else if (auto CS = dyn_cast_or_null(S)) { - if (CS->size() != 1) -break; - S = CS->body_back(); +else if (IgnoreCompound) { + if (auto CS = dyn_cast_or_null(S)) { +if (CS->size() != 1) + break; +S = CS->body_back(); + } else + break; } else break; } Index: include/clang/AST/Stmt.h === --- include/clang/AST/Stmt.h +++ include/clang/AST/Stmt.h @@ -388,9 +388,11 @@ /// statement, such as ExprWithCleanups or ImplicitCastExpr nodes. Stmt *IgnoreImplicit(); - /// \brief Skip no-op (attributed, compound) container stmts and skip captured - /// stmt at the top, if \a IgnoreCaptured is true. - Stmt *IgnoreContainers(bool IgnoreCaptured = false); + /// \brief Skip no-op (attributed, compound if \a IgnoreCompound is true) + /// container stmts and skip captured stmt at the top, if \a IgnoreCaptured + /// is true. + Stmt *IgnoreContainers(bool IgnoreCaptured = false, + bool IgnoreCompound = true); const Stmt *stripLabelLikeStatements() const; Stmt *stripLabelLikeStatements() { Index: test/OpenMP/for_loop_messages.cpp === --- test/OpenMP/for_loop_messages.cpp +++ test/OpenMP/for_loop_messages.cpp @@ -353,6 +353,14 @@ } #pragma omp parallel +// expected-error@+2 {{statement after '#pragma omp for' must be a for loop}} +#pragma omp for + { + for (int i = 0; i < 16; ++i) +; + } + +#pragma omp parallel // expected-note@+3 {{loop step is expected to be positive due to this condition}} // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} #pragma omp for Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -5133,7 +5133,8 @@ llvm::MapVector Captures; SmallVector IterSpaces; IterSpaces.resize(NestedLoopCount); - Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true); + Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true, + /* IgnoreCompound */ false); for (unsigned Cnt = 0; Cnt < NestedLoopCount; ++Cnt) { if (CheckOpenMPIterationSpace(DKind, CurStmt, SemaRef, DSA, Cnt, NestedLoopCount, CollapseLoopCountExpr, Index: lib/AST/Stmt.cpp
r283223 - [OpenMP] fix segfault when a variable referenced in reduction clause is a reference parameter\nDifferential Revision: http://reviews.llvm.org/D24524
Author: davidsh Date: Tue Oct 4 09:41:36 2016 New Revision: 283223 URL: http://llvm.org/viewvc/llvm-project?rev=283223=rev Log: [OpenMP] fix segfault when a variable referenced in reduction clause is a reference parameter\nDifferential Revision: http://reviews.llvm.org/D24524 Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp cfe/trunk/test/OpenMP/for_reduction_messages.cpp cfe/trunk/test/OpenMP/for_simd_reduction_messages.cpp cfe/trunk/test/OpenMP/parallel_for_reduction_messages.cpp cfe/trunk/test/OpenMP/parallel_for_simd_reduction_messages.cpp cfe/trunk/test/OpenMP/parallel_reduction_messages.cpp cfe/trunk/test/OpenMP/parallel_sections_reduction_messages.cpp cfe/trunk/test/OpenMP/sections_reduction_messages.cpp cfe/trunk/test/OpenMP/simd_reduction_messages.cpp cfe/trunk/test/OpenMP/target_parallel_for_reduction_messages.cpp cfe/trunk/test/OpenMP/target_parallel_for_simd_reduction_messages.cpp cfe/trunk/test/OpenMP/target_parallel_reduction_messages.cpp cfe/trunk/test/OpenMP/target_simd_reduction_messages.cpp cfe/trunk/test/OpenMP/teams_distribute_reduction_messages.cpp cfe/trunk/test/OpenMP/teams_reduction_messages.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=283223=283222=283223=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Tue Oct 4 09:41:36 2016 @@ -9401,7 +9401,7 @@ OMPClause *Sema::ActOnOpenMPReductionCla // for all threads of the team. if (!ASE && !OASE && VD) { VarDecl *VDDef = VD->getDefinition(); - if (VD->getType()->isReferenceType() && VDDef) { + if (VD->getType()->isReferenceType() && VDDef && VDDef->hasInit()) { DSARefChecker Check(DSAStack); if (Check.Visit(VDDef->getInit())) { Diag(ELoc, diag::err_omp_reduction_ref_type_arg) << ERange; Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp?rev=283223=283222=283223=diff == --- cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp (original) +++ cfe/trunk/test/OpenMP/distribute_parallel_for_reduction_messages.cpp Tue Oct 4 09:41:36 2016 @@ -9,6 +9,14 @@ bool foobool(int argc) { return argc; } +void foobar(int ) { +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for reduction(+:ref) + for (int i = 0; i < 10; ++i) +foo(); +} + struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}} extern S1 a; class S2 { Modified: cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp?rev=283223=283222=283223=diff == --- cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp (original) +++ cfe/trunk/test/OpenMP/distribute_parallel_for_simd_reduction_messages.cpp Tue Oct 4 09:41:36 2016 @@ -9,6 +9,14 @@ bool foobool(int argc) { return argc; } +void foobar(int ) { +#pragma omp target +#pragma omp teams +#pragma omp distribute parallel for simd reduction(+:ref) + for (int i = 0; i < 10; ++i) +foo(); +} + struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}} extern S1 a; class S2 { Modified: cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp?rev=283223=283222=283223=diff == --- cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp (original) +++ cfe/trunk/test/OpenMP/distribute_simd_reduction_messages.cpp Tue Oct 4 09:41:36 2016 @@ -9,6 +9,14 @@ bool foobool(int argc) { return argc; } +void foobar(int ) { +#pragma omp target +#pragma omp teams +#pragma omp distribute simd reduction(+:ref) + for (int i = 0; i < 10; ++i) +foo(); +} + struct S1; // expected-note {{declared here}} expected-note 4 {{forward declaration of 'S1'}} extern S1 a; class S2 { Modified: cfe/trunk/test/OpenMP/for_reduction_messages.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_reduction_messages.cpp?rev=283223=283222=283223=diff == ---
[PATCH] D24615: [OpenMP] clang doesnt diagnose if there is a lexical block around a for stmt for OpenMP loops. It is technically not allowed in the OpenMP standard
davidsh created this revision. davidsh added reviewers: carlo.bertolli, arpith-jacob, kkwli0, sfantao, ABataev. davidsh added a subscriber: cfe-commits. #pragma omp for { for(...) } This is technically not allowed by the standard, gcc doesnt allow such code. https://reviews.llvm.org/D24615 Files: lib/Sema/SemaOpenMP.cpp test/OpenMP/for_loop_messages.cpp Index: test/OpenMP/for_loop_messages.cpp === --- test/OpenMP/for_loop_messages.cpp +++ test/OpenMP/for_loop_messages.cpp @@ -353,6 +353,14 @@ } #pragma omp parallel +// expected-error@+2 {{statement after '#pragma omp for' must be a for loop}} +#pragma omp for + { + for (int i = 0; i < 16; ++i) +; + } + +#pragma omp parallel // expected-note@+3 {{loop step is expected to be positive due to this condition}} // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} #pragma omp for Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -5133,7 +5133,9 @@ llvm::MapVector Captures; SmallVectorIterSpaces; IterSpaces.resize(NestedLoopCount); - Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true); + Stmt *CurStmt = AStmt; + if (auto CapS = dyn_cast_or_null(CurStmt)) +CurStmt = CapS->getCapturedStmt(); for (unsigned Cnt = 0; Cnt < NestedLoopCount; ++Cnt) { if (CheckOpenMPIterationSpace(DKind, CurStmt, SemaRef, DSA, Cnt, NestedLoopCount, CollapseLoopCountExpr, Index: test/OpenMP/for_loop_messages.cpp === --- test/OpenMP/for_loop_messages.cpp +++ test/OpenMP/for_loop_messages.cpp @@ -353,6 +353,14 @@ } #pragma omp parallel +// expected-error@+2 {{statement after '#pragma omp for' must be a for loop}} +#pragma omp for + { + for (int i = 0; i < 16; ++i) +; + } + +#pragma omp parallel // expected-note@+3 {{loop step is expected to be positive due to this condition}} // expected-error@+2 {{increment expression must cause 'i' to increase on each iteration of OpenMP for loop}} #pragma omp for Index: lib/Sema/SemaOpenMP.cpp === --- lib/Sema/SemaOpenMP.cpp +++ lib/Sema/SemaOpenMP.cpp @@ -5133,7 +5133,9 @@ llvm::MapVector Captures; SmallVector IterSpaces; IterSpaces.resize(NestedLoopCount); - Stmt *CurStmt = AStmt->IgnoreContainers(/* IgnoreCaptured */ true); + Stmt *CurStmt = AStmt; + if (auto CapS = dyn_cast_or_null(CurStmt)) +CurStmt = CapS->getCapturedStmt(); for (unsigned Cnt = 0; Cnt < NestedLoopCount; ++Cnt) { if (CheckOpenMPIterationSpace(DKind, CurStmt, SemaRef, DSA, Cnt, NestedLoopCount, CollapseLoopCountExpr, ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits