Skip to content

Commit 29ae289

Browse files
committed
Tests for successful format string passthrough
1 parent caa3b33 commit 29ae289

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2+
3+
int printf(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float")));
4+
int myprintf(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"), format(printf, 1, 2)));
5+
6+
// CHECK-LABEL: define dso_local void @test_inferred_format(
7+
// CHECK: {{.*}} = call i32 (ptr, ...) @printf(ptr noundef @.str) #[[ATTR:[0-9]+]]
8+
void test_inferred_format(void) {
9+
printf("hello");
10+
}
11+
12+
// CHECK-LABEL: define dso_local void @test_explicit_format(
13+
// CHECK: {{.*}} = call i32 (ptr, ...) @myprintf(ptr noundef @.str) #[[ATTR:[0-9]+]]
14+
void test_explicit_format(void) {
15+
myprintf("hello");
16+
}
17+
18+
// CHECK: attributes #[[ATTR]] = { "modular-format"="printf,1,2,__modular_printf,__printf,float" }

0 commit comments

Comments
 (0)