This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
automatically concatenated string literals
- To: gcc-patches at gcc dot gnu dot org (gcc-patches at gcc dot gnu dot org)
- Subject: automatically concatenated string literals
- From: "Philippe De Muyter" <phdm at macqel dot be>
- Date: Sun, 12 Dec 1999 00:01:43 +0100 (CET)
Problem :
cc -c -DIN_GCC -g `case flow.o in combine.o|expr.o|decl.o|stb.o|cse.o) echo
-Wa,-j;;esac` -DHAVE_CONFIG_H -I. -I/share/src/gnu/egcs-19991201/gcc -I/shar
e/src/gnu/egcs-19991201/gcc/config -I/share/src/gnu/egcs-19991201/gcc/../include
/share/src/gnu/egcs-19991201/gcc/flow.c
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6030: warning: illegal pointer c
ombination, op =
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6033: warning: illegal pointer c
ombination, op =
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6432: syntax error
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6432: header undefined
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6432: d undefined
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6432: latch undefined
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6432: pre undefined
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6432: newline in string or char
constant
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6433: syntax error
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6433: illegal character: 134 (oc
tal)
"/share/src/gnu/egcs-19991201/gcc/flow.c", line 6433: cannot recover from earlie
r errors: goodbye!
Fix :
Sat Dec 11 23:46:01 1999 Philippe De Muyter <phdm@macqel.be>
* flow.c (create_edge_list): Cast xmalloc return value.
(flow_loops_dump): Use plain traditional constant strings, not
automatically concatenated string literals.
* c-common.c (combine_strings): With -Wtraditional, warn for
automatically concatenated string literals.
* invoke.texi (-Wtraditional) : Document it.
--- ./gcc/c-common.c Sat Dec 11 23:42:33 1999
+++ ./gcc/c-common.c Thu Dec 9 15:19:44 1999
@@ -324,6 +324,8 @@ combine_strings (strings)
/* More than one in the chain, so concatenate. */
register char *p, *q;
+ if (warn_traditional)
+ warning ("using automatic concatenation of adjacent string literals");
/* Don't include the \0 at the end of each substring,
except for the last one.
Count wide strings and ordinary strings separately. */
--- ./gcc/flow.c Sat Dec 11 23:42:34 1999
+++ ./gcc/flow.c Wed Dec 8 23:43:56 1999
@@ -6027,10 +6027,11 @@ create_edge_list ()
for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
num_edges++;
- elist = xmalloc (sizeof (struct edge_list));
+ elist = (struct edge_list *) xmalloc (sizeof (struct edge_list));
elist->num_blocks = block_count;
elist->num_edges = num_edges;
- elist->index_to_edge = xmalloc (sizeof (edge) * num_edges);
+ elist->index_to_edge = (struct edge_list *) xmalloc (sizeof (edge) *
+ num_edges);
num_edges = 0;
@@ -6428,9 +6429,8 @@ flow_loops_dump (loops, file, verbose)
{
struct loop *loop = &loops->array[i];
- fprintf (file, ";; loop %d (%d to %d):\n"
- ";; header %d, latch %d, pre-header %d,"
- " depth %d, level %d, outer %d\n",
+ fprintf (file, ";; loop %d (%d to %d):\n\
+;; header %d, latch %d, pre-header %d, depth %d, level %d, outer %d\n",
i, INSN_UID (loop->header->head), INSN_UID (loop->latch->end),
loop->header->index, loop->latch->index,
loop->pre_header ? loop->pre_header->index : -1,
@@ -6460,8 +6460,8 @@ flow_loops_dump (loops, file, verbose)
the larger of LOOP and OLOOP then LOOP and OLOOP
must be disjoint. */
disjoint = ! flow_loop_nested_p (smaller ? loop : oloop);
- fprintf (file, ";; loop header %d shared by loops %d, %d"
- " %s\n",
+ fprintf (file,
+ ";; loop header %d shared by loops %d, %d %s\n",
loop->header->index, i, j,
disjoint ? "disjoint" : "nested");
}
--- ./gcc/invoke.texi Sat Dec 11 23:42:35 1999
+++ ./gcc/invoke.texi Sat Dec 11 23:41:44 1999
@@ -1698,6 +1698,10 @@ foo (a)
signedness from its traditional type. This warning is only issued if
the base of the constant is ten. I.e. hexadecimal or octal values, which
typically represent bit patterns, are not warned about.
+
+@item
+A constant string is written as multiple adjacent string literals.
+This construct is not accepted by traditional C compilers.
@end itemize
@item -Wundef