build/clang-plugin/tests/TestMultipleAnnotations.cpp
author Kyle Machulis <kyle@nonpolynomial.com>
Fri, 11 Jan 2019 08:09:33 +0000
changeset 453529 85cbb065250d22e6d4e34fa5db536603cb205fbd
parent 295383 4fe5cc4663a37c77239fd9f3344d4816fa7c9ce6
permissions -rw-r--r--
Bug 1518956 - Make C++ infallible/simplified versions of nsIURI::SchemeIs; r=valentin SchemeIs only throws exceptions on null arguments now. Assert arguments, as they should never be null anyways, and create an infallible C++ version. Differential Revision: https://phabricator.services.mozilla.com/D16143

#define MOZ_MUST_USE_TYPE __attribute__((annotate("moz_must_use_type")))
#define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class")))

class MOZ_MUST_USE_TYPE MOZ_STACK_CLASS TestClass {};

TestClass foo; // expected-error {{variable of type 'TestClass' only valid on the stack}} expected-note {{value incorrectly allocated in a global variable}}

TestClass f()
{
  TestClass bar;
  return bar;
}

void g()
{
  f(); // expected-error {{Unused value of must-use type 'TestClass'}}
}