This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] C++ Fix charset bug, testsuite problem, new testcases
- From: Eric Christopher <echristo at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 19 Mar 2004 17:35:21 -0800
- Subject: [PATCH] C++ Fix charset bug, testsuite problem, new testcases
Fixes the case that I'd not thought about, but is apparently legal:
extern void foo (void)
{ ... }
Fixed by moving the translation variable up about 30 lines.
Added a new test to both C and C++ for this. C didn't have the problem
to begin with, but better safe than sorry.
In figuring out why my test didn't run I came across that I wasn't
running any .cc files so I fixed that as well.
It seems obvious, but I figure I should ask first.
OK?
-eric
--
Eric Christopher <echristo@redhat.com>
gcc/ChangeLog
2004-03-19 Eric Christopher <echristo@redhat.com>
* cp/parser.c (cp_parser_declaration): Move
translation switch earlier in function.
gcc/testsuite/ChangeLog
2004-03-19 Eric Christopher <echristo@redhat.com>
* gcc.dg/charset/extern.c: New file.
* g++.dg/charset/extern3.cc: Ditto.
* g++.dg/charset/charset.exp: Test .cc
files.
Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.183
diff -u -p -w -r1.183 parser.c
--- cp/parser.c 16 Mar 2004 22:17:59 -0000 1.183
+++ cp/parser.c 20 Mar 2004 01:25:00 -0000
@@ -6340,6 +6340,8 @@ cp_parser_declaration (cp_parser* parser
if (token1.type != CPP_EOF)
token2 = *cp_lexer_peek_nth_token (parser->lexer, 2);
+ c_lex_string_translate = true;
+
/* If the next token is `extern' and the following token is a string
literal, then we have a linkage specification. */
if (token1.keyword == RID_EXTERN
@@ -6389,8 +6391,6 @@ cp_parser_declaration (cp_parser* parser
else
/* Try to parse a block-declaration, or a function-definition. */
cp_parser_block_declaration (parser, /*statement_p=*/false);
-
- c_lex_string_translate = true;
}
/* Parse a block-declaration.
Index: testsuite/g++.dg/charset/charset.exp
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/charset/charset.exp,v
retrieving revision 1.2
diff -u -p -w -r1.2 charset.exp
--- testsuite/g++.dg/charset/charset.exp 28 Feb 2004 00:28:54 -0000 1.2
+++ testsuite/g++.dg/charset/charset.exp 20 Mar 2004 01:25:03 -0000
@@ -37,7 +37,7 @@ if ![info exists DEFAULT_CHARSETCFLAGS]
dg-init
# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,S} ]] \
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{c,cc,S} ]] \
"" $DEFAULT_CHARSETCFLAGS
# All done.
Index: testsuite/g++.dg/charset/extern3.cc
===================================================================
RCS file: testsuite/g++.dg/charset/extern3.cc
diff -N testsuite/g++.dg/charset/extern3.cc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/g++.dg/charset/extern3.cc 20 Mar 2004 01:25:03 -0000
@@ -0,0 +1,8 @@
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler-not "abcdefghijklmnopqrstuvwxyz" } } */
+
+extern void foo (void)
+{
+ char str[]="abcdefghijklmnopqrstuvwxyz";
+}
Index: testsuite/gcc.dg/charset/extern.c
===================================================================
RCS file: testsuite/gcc.dg/charset/extern.c
diff -N testsuite/gcc.dg/charset/extern.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/charset/extern.c 20 Mar 2004 01:25:05 -0000
@@ -0,0 +1,8 @@
+/* { dg-do compile }
+ { dg-require-iconv "IBM-1047" }
+ { dg-final { scan-assembler-not "abcdefghijklmnopqrstuvwxyz" } } */
+
+extern void foo (void)
+{
+ char str[]="abcdefghijklmnopqrstuvwxyz";
+}