Skip to content

Commit 6825ed6

Browse files
authored
printf GNU extentions: Add more tests (#12109)
1 parent 3e2a489 commit 6825ed6

File tree

1 file changed

+52
-2
lines changed

1 file changed

+52
-2
lines changed

test/compilable/test21177.d

+52-2
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,74 @@
33
DISABLED: win
44
TEST_OUTPUT:
55
---
6-
compilable/test21177.d(19): Deprecation: more format specifiers than 0 arguments
6+
compilable/test21177.d(103): Deprecation: more format specifiers than 0 arguments
7+
compilable/test21177.d(150): Deprecation: more format specifiers than 0 arguments
8+
compilable/test21177.d(151): Deprecation: more format specifiers than 0 arguments
9+
compilable/test21177.d(152): Deprecation: more format specifiers than 0 arguments
10+
compilable/test21177.d(153): Deprecation: more format specifiers than 0 arguments
11+
compilable/test21177.d(200): Deprecation: more format specifiers than 0 arguments
12+
compilable/test21177.d(203): Deprecation: format specifier `"%m"` is invalid
13+
compilable/test21177.d(204): Deprecation: format specifier `"%m"` is invalid
14+
compilable/test21177.d(205): Deprecation: argument `c` for format specification `"%a"` must be `float*`, not `char*`
15+
compilable/test21177.d(206): Deprecation: argument `c` for format specification `"%a"` must be `float*`, not `char*`
716
---
817
*/
918

1019
import core.stdc.stdio;
20+
import core.stdc.string;
21+
import core.stdc.stdlib;
1122

1223
void main()
1324
{
1425
version (CRuntime_Glibc)
1526
{
27+
#line 100
1628
printf("%m this is a string in errno");
1729
printf("%s %m", "str".ptr, 2);
1830
printf("%a", 2.);
1931
printf("%m %m %s");
32+
printf("%*m");
33+
34+
char* a, b;
35+
sscanf("salut poilu", "%a %m", a, b);
36+
assert(!strcmp(a, b));
37+
free(a);
38+
free(b);
39+
40+
char* t, p;
41+
sscanf("Tomate Patate", "%ms %as", t, p);
42+
free(t);
43+
free(p);
44+
45+
#line 150
46+
sscanf("150", "%m");
47+
sscanf("151", "%ms");
48+
sscanf("152", "%a");
49+
sscanf("153", "%as");
50+
51+
pragma(msg, "compilable/test21177.d(200): Deprecation: more format specifiers than 0 arguments");
52+
pragma(msg, "compilable/test21177.d(203): Deprecation: format specifier `\"%m\"` is invalid");
53+
pragma(msg, "compilable/test21177.d(204): Deprecation: format specifier `\"%m\"` is invalid");
54+
pragma(msg, "compilable/test21177.d(205): Deprecation: argument `c` for format specification `\"%a\"` must be `float*`, not `char*`");
55+
pragma(msg, "compilable/test21177.d(206): Deprecation: argument `c` for format specification `\"%a\"` must be `float*`, not `char*`");
2056
}
2157
else
2258
{
2359
// fake it
24-
pragma(msg, "compilable/test21177.d(19): Deprecation: more format specifiers than 0 arguments");
60+
pragma(msg, "compilable/test21177.d(103): Deprecation: more format specifiers than 0 arguments");
61+
pragma(msg, "compilable/test21177.d(150): Deprecation: more format specifiers than 0 arguments");
62+
pragma(msg, "compilable/test21177.d(151): Deprecation: more format specifiers than 0 arguments");
63+
pragma(msg, "compilable/test21177.d(152): Deprecation: more format specifiers than 0 arguments");
64+
pragma(msg, "compilable/test21177.d(153): Deprecation: more format specifiers than 0 arguments");
65+
66+
#line 200
67+
printf("%m");
68+
69+
char* c;
70+
sscanf("204", "%m", c);
71+
sscanf("205", "%ms", c);
72+
sscanf("206", "%a", c);
73+
sscanf("207", "%as", c);
74+
2575
}
2676
}

0 commit comments

Comments
 (0)