build/clang-plugin/tests/TestMultipleAnnotations.cpp
author Nicholas Nethercote <nnethercote@mozilla.com>
Wed, 27 Apr 2016 08:22:10 +1000
changeset 295383 4fe5cc4663a37c77239fd9f3344d4816fa7c9ce6
parent 257031 0d6871d66dc07cda204c3814a488f6dafe019507
permissions -rw-r--r--
Bug 1267550 (part 1) - Rename MOZ_MUST_USE as MOZ_MUST_USE_TYPE. r=ehsan. This will allow MOZ_MUST_USE to be used for a different and more common case. MozReview-Commit-ID: 4dQsdWjJfc6

#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'}}
}