1/* Check that constant constraints like "i", "n" and "s" can be used in 2 cases where the operand is an initializer constant. */ 3/* { dg-require-effective-target nonpic } */ 4 5int x[2] = { 1, 2 }; 6 7#ifdef __OPTIMIZE__ 8static inline void __attribute__((__always_inline__)) 9insn1 (int x) 10{ 11 asm volatile ("" :: "n" (x), "i" (x)); 12} 13 14static inline void __attribute__((__always_inline__)) 15insn2 (const void *x) 16{ 17 asm volatile ("" :: "s" (x), "i" (x)); 18} 19#endif 20 21void 22foo (void) 23{ 24#ifdef __OPTIMIZE__ 25 insn1 (2); 26 insn1 (2); 27 insn1 (400); 28 insn1 (__LINE__); 29 insn2 (x); 30 insn2 (x); 31 insn2 (&x[1]); 32 insn2 ("string"); 33#endif 34 asm volatile ("" :: "s" (x), "i" (x)); 35 /* At the time of writing, &x[1] is decomposed before reaching expand 36 when compiling with -O0. */ 37 asm volatile ("" :: "s" ("string"), "i" ("string")); 38 asm volatile ("" :: "s" (__FILE__), "i" (__FILE__)); 39 asm volatile ("" :: "s" (__FUNCTION__), "i" (__FUNCTION__)); 40} 41