From c60e13aeff96515d27638129154b1308c15ded3d Mon Sep 17 00:00:00 2001 From: Jeffrey Yasskin Date: Tue, 25 Jan 2011 20:08:12 +0000 Subject: [PATCH] Add an attribute to forbid temporary instances of a type. This allows class authors to write class __attribute__((forbid_temporaries)) Name { ... }; when they want to force users to name all variables of the type. This protects people from doing things like creating a scoped_lock that only lives for a single statement instead of an entire scope. The warning produced by this attribute can be disabled by -Wno-forbid-temporaries. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124217 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/LanguageExtensions.html | 28 ++++++++++++ include/clang/Basic/Attr.td | 5 +++ include/clang/Basic/DiagnosticSemaKinds.td | 3 ++ include/clang/Sema/AttributeList.h | 1 + lib/Sema/AttributeList.cpp | 1 + lib/Sema/SemaDeclAttr.cpp | 20 +++++++++ lib/Sema/SemaExprCXX.cpp | 5 ++- test/SemaCXX/forbid-temporaries.cpp | 50 ++++++++++++++++++++++ 8 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 test/SemaCXX/forbid-temporaries.cpp diff --git a/docs/LanguageExtensions.html b/docs/LanguageExtensions.html index 78c3cd50bf..06b01db760 100644 --- a/docs/LanguageExtensions.html +++ b/docs/LanguageExtensions.html @@ -25,6 +25,7 @@ td {
  • Vectors and Extended Vectors
  • Messages on deprecated and unavailable attributes
  • Attributes on enumerators
  • +
  • Attribute to forbid temporaries of a type
  • Checks for Standard Language Features