Author: Alexey Bataev
Date: 2020-01-03T12:13:03-05:00
New Revision: add743b4348095c0d2e407c7a2b8a87a5f8194b0

URL: 
https://github.com/llvm/llvm-project/commit/add743b4348095c0d2e407c7a2b8a87a5f8194b0
DIFF: 
https://github.com/llvm/llvm-project/commit/add743b4348095c0d2e407c7a2b8a87a5f8194b0.diff

LOG: [OPENMP]Fix crash on error message for declare reduction.

If the qualified reduction name is specified and not found, the compiler
may crash because of not specified parameter.

Added: 
    

Modified: 
    clang/lib/Sema/SemaOpenMP.cpp
    clang/test/OpenMP/declare_reduction_messages.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 5a4254f11a8b..d2393c17bcc8 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -13498,7 +13498,8 @@ buildDeclareReductionRef(Sema &SemaRef, SourceLocation 
Loc, SourceRange Range,
     }
   }
   if (ReductionIdScopeSpec.isSet()) {
-    SemaRef.Diag(Loc, diag::err_omp_not_resolved_reduction_identifier) << 
Range;
+    SemaRef.Diag(Loc, diag::err_omp_not_resolved_reduction_identifier)
+        << Ty << Range;
     return ExprError();
   }
   return ExprEmpty();

diff  --git a/clang/test/OpenMP/declare_reduction_messages.cpp 
b/clang/test/OpenMP/declare_reduction_messages.cpp
index 1fc5ec6e683f..eeafe9032e08 100644
--- a/clang/test/OpenMP/declare_reduction_messages.cpp
+++ b/clang/test/OpenMP/declare_reduction_messages.cpp
@@ -146,9 +146,9 @@ struct A {
 };
 
 int A_TEST() {
-  A test;
+  A test, test1;
 #pragma omp declare reduction(+ : A : omp_out) initializer(omp_priv = A()) 
allocate(test) // expected-warning {{extra tokens at the end of '#pragma omp 
declare reduction' are ignored}}
-#pragma omp parallel reduction(+ : test)
+#pragma omp parallel reduction(+ : test) reduction(::operator+: test1) // 
expected-error {{unable to resolve declare reduction construct for type 'A'}}
   {}
   return 0;
 }


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to