diff options
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/Store.cpp | 5 | ||||
-rw-r--r-- | clang/test/Analysis/ptr-arith.c | 5 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/Store.cpp b/clang/lib/StaticAnalyzer/Core/Store.cpp index 1af49f68cc0..173fdd8d005 100644 --- a/clang/lib/StaticAnalyzer/Core/Store.cpp +++ b/clang/lib/StaticAnalyzer/Core/Store.cpp @@ -440,7 +440,10 @@ SVal StoreManager::getLValueElement(QualType elementType, NonLoc Offset, // value. See also the similar FIXME in getLValueFieldOrIvar(). if (Base.isUnknownOrUndef() || Base.getAs<loc::ConcreteInt>()) return Base; - + + if (Base.getAs<loc::GotoLabel>()) + return UnknownVal(); + const SubRegion *BaseRegion = Base.castAs<loc::MemRegionVal>().getRegionAs<SubRegion>(); diff --git a/clang/test/Analysis/ptr-arith.c b/clang/test/Analysis/ptr-arith.c index b78ec503a1c..93cb4ee9a66 100644 --- a/clang/test/Analysis/ptr-arith.c +++ b/clang/test/Analysis/ptr-arith.c @@ -342,3 +342,8 @@ void negativeIndex(char *str) { clang_analyzer_eval(*ptr3 == 'a'); // expected-warning{{UNKNOWN}} } +void test_no_crash_on_pointer_to_label() { + char *a = &&label; + a[0] = 0; +label:; +} |