This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[4.1 PATCH] Fix -xassembler-with-cpp -std=xxx (PR c/25993)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 3 Jan 2007 18:42:28 -0500
- Subject: [4.1 PATCH] Fix -xassembler-with-cpp -std=xxx (PR c/25993)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
This is a P1, fixed on 4.2+. Ok for 4.1 branch as well?
Bootstrapped/regtested on {x86_64,ia64,s390,s390x}-linux.
2007-01-03 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
2006-09-17 Steven Bosscher <steven@gcc.gnu.org>
PR c/25993
* c-opts.c (c_common_handle_option): Ignore the -std options
if the input language is assembly.
2006-10-13 Eric Christopher <echristo@apple.com>
* gcc.dg/pr25993.c: Skip for darwin.
2006-09-16 Steven Bosscher <steven@gcc.gnu.org>
PR c/25993
* gcc.dg/pr25993.c: New test.
--- gcc/c-opts.c (revision 117004)
+++ gcc/c-opts.c (revision 117005)
@@ -268,6 +268,10 @@ c_common_handle_option (size_t scode, co
enum opt_code code = (enum opt_code) scode;
int result = 1;
+ /* Prevent resetting the language standard to a C dialect when the driver
+ has already determined that we're looking at assembler input. */
+ bool preprocessing_asm_p = (cpp_get_options (parse_in)->lang == CLK_ASM);
+
switch (code)
{
default:
@@ -905,29 +909,34 @@ c_common_handle_option (size_t scode, co
case OPT_std_c__98:
case OPT_std_gnu__98:
- set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
+ if (!preprocessing_asm_p)
+ set_std_cxx98 (code == OPT_std_c__98 /* ISO */);
break;
case OPT_std_c89:
case OPT_std_iso9899_1990:
case OPT_std_iso9899_199409:
- set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
+ if (!preprocessing_asm_p)
+ set_std_c89 (code == OPT_std_iso9899_199409 /* c94 */, true /* ISO */);
break;
case OPT_std_gnu89:
- set_std_c89 (false /* c94 */, false /* ISO */);
+ if (!preprocessing_asm_p)
+ set_std_c89 (false /* c94 */, false /* ISO */);
break;
case OPT_std_c99:
case OPT_std_c9x:
case OPT_std_iso9899_1999:
case OPT_std_iso9899_199x:
- set_std_c99 (true /* ISO */);
+ if (!preprocessing_asm_p)
+ set_std_c99 (true /* ISO */);
break;
case OPT_std_gnu99:
case OPT_std_gnu9x:
- set_std_c99 (false /* ISO */);
+ if (!preprocessing_asm_p)
+ set_std_c99 (false /* ISO */);
break;
case OPT_trigraphs:
--- gcc/testsuite/gcc.dg/pr25993.c (revision 0)
+++ gcc/testsuite/gcc.dg/pr25993.c (revision 117005)
@@ -0,0 +1,14 @@
+/* { dg-do assemble { target i?86-*-* x86_64-*-* } } */
+/* { dg-skip-if "" { "*-*-darwin*" } { "*" } { "" } } */
+/* { dg-options "-std=c99 -x assembler-with-cpp" } */
+
+#ifndef __ASSEMBLER__
+extern int func(void);
+#else
+.global func
+.type func,%function
+.align 4
+func:
+ ret
+.size func,.-func
+#endif
Jakub