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

llvm-svn: 245939
This commit is contained in:
Alexey Bataev
2015-08-25 15:15:12 +00:00
parent 933e230738
commit 627cbd31d1
2 changed files with 5 additions and 2 deletions

View 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);

View 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;