2018-07-20 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / diagnostic / pr70105.C
blob55d55973204da25110946f4524ab3259680dff64
1 // { dg-options "-Wsequence-point -fdiagnostics-show-caret" }
2 // { dg-require-effective-target alloca }
4 void *libiberty_concat_ptr;
5 extern unsigned long concat_length (const char *, ...);
6 extern char *concat_copy2 (const char *, ...);
8 #define ACONCAT(ACONCAT_PARAMS) \
9   (libiberty_concat_ptr = (char *) ALLOCA (concat_length ACONCAT_PARAMS + 1), /* { dg-warning "may be undefined" } */ \
10    concat_copy2 ACONCAT_PARAMS)
12 /* Arbitrary content here.
13    In PR c++/70105, this was >500 lines of source.
14    This should not be printed.  */
16 # define ALLOCA(x) __builtin_alloca(x)
18 int strlen (const char *);
19 void *get_identifier (const char *);
20 void *get_identifier_with_length (const char *, int);
22 #define GET_IDENTIFIER(STR) \
23   (__builtin_constant_p (STR)                           \
24     ? get_identifier_with_length ((STR), strlen (STR))  \
25     : get_identifier (STR))
27 void *test(void)
29   int *i;
30   return GET_IDENTIFIER (ACONCAT (("foo")));
33 /* { dg-begin-multiline-output "" }
34    (libiberty_concat_ptr = (char *) ALLOCA (concat_length ACONCAT_PARAMS + 1),
35                          ^
36    { dg-end-multiline-output "" } */
37 /* { dg-begin-multiline-output "" }
38      ? get_identifier_with_length ((STR), strlen (STR))  \
39                                                   ^~~
40    { dg-end-multiline-output "" } */
41 /* { dg-begin-multiline-output "" }
42    return GET_IDENTIFIER (ACONCAT (("foo")));
43                           ^~~~~~~
44    { dg-end-multiline-output "" } */