mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-23 10:54:33 +00:00

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
18 lines
490 B
C++
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'}}
|
|
}
|