summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Checker/GRExprEngine.cpp3
-rw-r--r--clang/test/Analysis/misc-ps-region-store.cpp16
2 files changed, 19 insertions, 0 deletions
diff --git a/clang/lib/Checker/GRExprEngine.cpp b/clang/lib/Checker/GRExprEngine.cpp
index 73fc9262605..9ee723eb7c5 100644
--- a/clang/lib/Checker/GRExprEngine.cpp
+++ b/clang/lib/Checker/GRExprEngine.cpp
@@ -1058,6 +1058,9 @@ void GRExprEngine::VisitLValue(const Expr* Ex, ExplodedNode* Pred,
// In C++, binding an rvalue to a reference requires to create an object.
case Stmt::CXXBoolLiteralExprClass:
case Stmt::IntegerLiteralClass:
+ case Stmt::CharacterLiteralClass:
+ case Stmt::FloatingLiteralClass:
+ case Stmt::ImaginaryLiteralClass:
CreateCXXTemporaryObject(Ex, Pred, Dst);
return;
diff --git a/clang/test/Analysis/misc-ps-region-store.cpp b/clang/test/Analysis/misc-ps-region-store.cpp
index 6794d481d68..baaa2f6cbd0 100644
--- a/clang/test/Analysis/misc-ps-region-store.cpp
+++ b/clang/test/Analysis/misc-ps-region-store.cpp
@@ -132,3 +132,19 @@ int TestHandleThis::null_deref_positive() {
return 0;
}
+// PR 7675 - passing literals by-reference
+void pr7675(const double &a);
+void pr7675(const int &a);
+void pr7675(const char &a);
+void pr7675_i(const _Complex double &a);
+
+void pr7675_test() {
+ pr7675(10.0);
+ pr7675(10);
+ pr7675('c');
+ pr7675_i(4.0i);
+ // Add null deref to ensure we are analyzing the code up to this point.
+ int *p = 0;
+ *p = 0xDEADBEEF; // expected-warning{{null pointer}}
+}
+
OpenPOWER on IntegriCloud