gecko-dev/build/clang-plugin/tests/TestMultipleAnnotations.cpp
Nicholas Nethercote a5c843fe5f 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

--HG--
extra : rebase_source : 390ab56ef83d71eb6d28759a0195a79a78b153bd
2016-04-27 08:22:10 +10:00

18 lines
490 B
C++

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