1 // Bug c++/83871 - wrong code due to attributes on distinct template
3 // Test to verify that an explicit template specifialization does not
4 // "inherit" attribute optimize from a primary template declared with
7 // { dg-options "-O2 -Wall -fdump-tree-optimized" }
11 void foptimize_none_primary_failed ();
14 void __attribute__ ((optimize ("no-printf-return-value")))
17 // The call to snprintf and the test should be retained.
18 if (2 != __builtin_snprintf (0, 0, "%hhx", 0x12))
19 foptimize_none_primary_failed ();
22 void foptimize_none_special_failed ();
26 foptimize_none<Special>()
28 // The whole if statement should be eliminated.
29 if (3 != __builtin_snprintf (0, 0, "1%hhx", 0x12))
30 foptimize_none_special_failed ();
35 foptimize_none<void>();
36 // { dg-final { scan-tree-dump-times "foptimize_none_primary_failed *\\(\\)" 1 "optimized" } }
41 // Should be eliminated.
42 foptimize_none<Special>();
43 // { dg-final { scan-tree-dump-not "foptimize_none_special_failed *\\(\\)" "optimized" } }
46 // { dg-final { scan-tree-dump-times "__builtin_snprintf" 1 "optimized" } }