]> granicus.if.org Git - clang/commit
Add a warning for when an array-to-pointer decay is performed on an array
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 4 Jun 2012 22:27:30 +0000 (22:27 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 4 Jun 2012 22:27:30 +0000 (22:27 +0000)
commit36d02af300a207242f0486b4255420d8be796b21
treeadb96320cd351324f25e5d0f3de39541f840d7cc
parentd5edd849b6003b97e0e1ee5cf964c10affbe6bce
Add a warning for when an array-to-pointer decay is performed on an array
temporary or an array subobject of a class temporary, and the resulting value
is used to initialize a pointer which outlives the temporary. Such a pointer
is always left dangling after the initialization completes and the array's
lifetime ends.

In order to detect this situation, this change also adds an
LValueClassification of LV_ArrayTemporary for temporaries of array type which
aren't subobjects of class temporaries. These occur in C++11 T{...} and GNU C++
(T){...} expressions, when T is an array type. Previously we treated the former
as a generic prvalue and the latter as a class temporary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@157955 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/AST/Expr.h
include/clang/Basic/DiagnosticSemaKinds.td
lib/AST/ExprClassification.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaInit.cpp
test/SemaCXX/address-of-temporary.cpp