summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-05-23 01:32:17 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-05-23 01:32:17 +0000
commit7800f1f5aa04876e327f6522118bc642c1c43532 (patch)
tree6aee211c6ffebfb4296fe47d19e297161f186eed /clang
parentd5aa33525c349a585a197c55a7dfd69e3ae2d41e (diff)
downloadbcm5719-llvm-7800f1f5aa04876e327f6522118bc642c1c43532.tar.gz
bcm5719-llvm-7800f1f5aa04876e327f6522118bc642c1c43532.zip
[Sema] Don't use dyn_cast to detect an AtomicType
An AtomicType might be hidden behind arbitrary levels of typedefs. getAs<> will reliably walk through the sugar to get the underlying AtomicType. This fixes PR23638. llvm-svn: 238083
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp2
-rw-r--r--clang/test/Sema/atomic-compare.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a64932b1c71..23a6fc3c4cd 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6100,7 +6100,7 @@ static void DiagnoseOutOfRangeComparison(Sema &S, BinaryOperator *E,
// TODO: Investigate using GetExprRange() to get tighter bounds
// on the bit ranges.
QualType OtherT = Other->getType();
- if (const AtomicType *AT = dyn_cast<AtomicType>(OtherT))
+ if (const auto *AT = OtherT->getAs<AtomicType>())
OtherT = AT->getValueType();
IntRange OtherRange = IntRange::forValueOfType(S.Context, OtherT);
unsigned OtherWidth = OtherRange.Width;
diff --git a/clang/test/Sema/atomic-compare.c b/clang/test/Sema/atomic-compare.c
index 2eed0912602..01eb8200472 100644
--- a/clang/test/Sema/atomic-compare.c
+++ b/clang/test/Sema/atomic-compare.c
@@ -19,3 +19,8 @@ void f(_Atomic(int) a, _Atomic(int) b) {
if (!a > b) {} // no warning
if (!a > -1) {} // expected-warning {{comparison of constant -1 with boolean expression is always true}}
}
+
+typedef _Atomic(int) Ty;
+void PR23638(Ty *a) {
+ if (*a == 1) {} // no warning
+}
OpenPOWER on IntegriCloud