r245939 - Fix possible crash on null base or type for array elements.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 25 08:15:12 PDT 2015


Author: abataev
Date: Tue Aug 25 10:15:12 2015
New Revision: 245939

URL: http://llvm.org/viewvc/llvm-project?rev=245939&view=rev
Log:
Fix possible crash on null base or type for array elements.


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/OpenMP/task_depend_messages.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=245939&r1=245938&r2=245939&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug 25 10:15:12 2015
@@ -3932,7 +3932,8 @@ static bool checkArithmeticOnObjCPointer
 ExprResult
 Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base, SourceLocation lbLoc,
                               Expr *idx, SourceLocation rbLoc) {
-  if (base->getType()->isSpecificPlaceholderType(BuiltinType::OMPArraySection))
+  if (base && !base->getType().isNull() &&
+      base->getType()->isSpecificPlaceholderType(BuiltinType::OMPArraySection))
     return ActOnOMPArraySectionExpr(base, lbLoc, idx, SourceLocation(),
                                     /*Length=*/nullptr, rbLoc);
 

Modified: cfe/trunk/test/OpenMP/task_depend_messages.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/task_depend_messages.cpp?rev=245939&r1=245938&r2=245939&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/task_depend_messages.cpp (original)
+++ cfe/trunk/test/OpenMP/task_depend_messages.cpp Tue Aug 25 10:15:12 2015
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
+// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - -std=c++11 %s
 
 void foo() {
 }
@@ -18,6 +18,7 @@ int main(int argc, char **argv, char *en
   vector vec;
   typedef float V __attribute__((vector_size(16)));
   V a;
+  auto arr = x; // expected-error {{use of undeclared identifier 'x'}}
 
   #pragma omp task depend // expected-error {{expected '(' after 'depend'}}
   #pragma omp task depend ( // expected-error {{expected 'in', 'out' or 'inout' in OpenMP clause 'depend'}} expected-error {{expected ')'}} expected-note {{to match this '('}} expected-warning {{missing ':' after dependency type - ignoring}}
@@ -48,6 +49,7 @@ int main(int argc, char **argv, char *en
   #pragma omp task depend(in:argv[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is not an array}}
   #pragma omp task depend(in:env[0:][:]) // expected-error {{section length is unspecified and cannot be inferred because subscripted value is an array of unknown bound}}
   #pragma omp task depend(in : argv[ : argc][1 : argc - 1])
+  #pragma omp task depend(in : arr[0])
   foo();
 
   return 0;




More information about the cfe-commits mailing list