]> granicus.if.org Git - clang/commitdiff
Fix possible crash on null base or type for array elements.
authorAlexey Bataev <a.bataev@hotmail.com>
Tue, 25 Aug 2015 15:15:12 +0000 (15:15 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Tue, 25 Aug 2015 15:15:12 +0000 (15:15 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@245939 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp
test/OpenMP/task_depend_messages.cpp

index e1430e3a2acae55e1e1f7e268dd948538623c4ee..f2c0fb82eefddcd45b670c2ab34048b52457945a 100644 (file)
@@ -3932,7 +3932,8 @@ static bool checkArithmeticOnObjCPointer(Sema &S,
 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);
 
index 3c3aea28aec0325e658bbaf731083aac52305df0..be96d8ec65f5107ee56017894ebdaccf07b16009 100644 (file)
@@ -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 *env[]) {
   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 *env[]) {
   #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;