aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/warn/Wunused-result-2.C
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/g++.dg/warn/Wunused-result-2.C')
-rw-r--r--gcc/testsuite/g++.dg/warn/Wunused-result-2.C21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/warn/Wunused-result-2.C b/gcc/testsuite/g++.dg/warn/Wunused-result-2.C
new file mode 100644
index 0000000..56ed17a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wunused-result-2.C
@@ -0,0 +1,21 @@
+// PR c++/66177
+
+struct QSize
+{
+ QSize(int w, int h) : wd(w), ht(h) {}
+
+ QSize expandedTo() const __attribute__ ((__warn_unused_result__))
+ {
+ return QSize(2, 3);
+ }
+
+private:
+ int wd;
+ int ht;
+};
+
+void foo()
+{
+ QSize sz(2, 2);
+ sz.expandedTo(); // { dg-warning "warn_unused_result" }
+}