summaryrefslogtreecommitdiffstats
path: root/test/Analysis/plist-macros-with-expansion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/plist-macros-with-expansion.cpp')
-rw-r--r--test/Analysis/plist-macros-with-expansion.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/Analysis/plist-macros-with-expansion.cpp b/test/Analysis/plist-macros-with-expansion.cpp
index c3175a3321..c062a4782c 100644
--- a/test/Analysis/plist-macros-with-expansion.cpp
+++ b/test/Analysis/plist-macros-with-expansion.cpp
@@ -440,3 +440,32 @@ void test() {
}
// CHECK: <key>name</key><string>YET_ANOTHER_SET_TO_NULL</string>
// CHECK-NEXT: <key>expansion</key><string>print((void *)5); print((void *)&quot;Remember the Vasa&quot;); ptr = nullptr;</string>
+
+int garbage_value;
+
+#define REC_MACRO_FUNC(REC_MACRO_PARAM) garbage_##REC_MACRO_PARAM
+#define value REC_MACRO_FUNC(value)
+
+void recursiveMacroUser() {
+ if (value == 0)
+ 1 / value; // expected-warning{{Division by zero}}
+ // expected-warning@-1{{expression result unused}}
+}
+
+#define FOO(x) int foo() { return x; }
+#define APPLY_ZERO1(function) function(0)
+
+APPLY_ZERO1(FOO)
+void useZeroApplier1() { (void)(1 / foo()); } // expected-warning{{Division by zero}}
+
+// CHECK: <key>name</key><string>APPLY_ZERO1</string>
+// CHECK-NEXT: <key>expansion</key><string>int foo() { return x; }(0)</string>
+
+#define BAR(x) int bar() { return x; }
+#define APPLY_ZERO2 BAR(0)
+
+APPLY_ZERO2
+void useZeroApplier2() { (void)(1 / bar()); } // expected-warning{{Division by zero}}
+
+// CHECK: <key>name</key><string>APPLY_ZERO2</string>
+// CHECK-NEXT: <key>expansion</key><string>int bar() { return 0; }</string>