181 lines
5.0 KiB
Diff
181 lines
5.0 KiB
Diff
2011-02-02 Tom Tromey <tromey@redhat.com>
|
|
|
|
* c-parser.c (c_parser_asm_string_literal): Clear
|
|
warn_overlength_strings.
|
|
|
|
* gcc.dg/Woverlength-strings-pedantic-c90-asm.c: New file.
|
|
* gcc.dg/Woverlength-strings-pedantic-c89-asm.c: New file.
|
|
* gcc.dg/Woverlength-strings-pedantic-c99-asm.c: New file.
|
|
|
|
--- gcc/c-parser.c
|
|
+++ gcc/c-parser.c
|
|
@@ -3264,6 +3264,8 @@ static tree
|
|
c_parser_asm_string_literal (c_parser *parser)
|
|
{
|
|
tree str;
|
|
+ int save_flag = warn_overlength_strings;
|
|
+ warn_overlength_strings = 0;
|
|
if (c_parser_next_token_is (parser, CPP_STRING))
|
|
{
|
|
str = c_parser_peek_token (parser)->value;
|
|
@@ -3281,6 +3283,7 @@ c_parser_asm_string_literal (c_parser *parser)
|
|
c_parser_error (parser, "expected string literal");
|
|
str = NULL_TREE;
|
|
}
|
|
+ warn_overlength_strings = save_flag;
|
|
return str;
|
|
}
|
|
|
|
--- gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-asm.c
|
|
+++ gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-asm.c
|
|
@@ -0,0 +1,47 @@
|
|
+/* -Woverlength-strings complains about string constants which are too long
|
|
+ for the C standard's "minimum maximum" limits. It is off by default,
|
|
+ but implied by -pedantic. */
|
|
+
|
|
+/* { dg-options "-std=c89 -pedantic" } */
|
|
+
|
|
+#define TEN " "
|
|
+#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
|
|
+#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
|
|
+
|
|
+/* C89's minimum-maximum is 509. */
|
|
+__asm__ (HUN HUN HUN HUN HUN TEN);
|
|
+
|
|
+/* C99's minimum-maximum is 4095. */
|
|
+__asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456");
|
|
+
|
|
+void
|
|
+f (void)
|
|
+{
|
|
+ /* C89's minimum-maximum is 509. */
|
|
+ __asm__ (HUN HUN HUN HUN HUN TEN);
|
|
+ __asm__ (HUN HUN HUN HUN HUN TEN : : );
|
|
+ __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label);
|
|
+
|
|
+ /* C99's minimum-maximum is 4095. */
|
|
+ __asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456");
|
|
+ __asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456" : : );
|
|
+ __asm__ goto (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456" : : : : label);
|
|
+
|
|
+ label: ;
|
|
+}
|
|
--- gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-asm.c
|
|
+++ gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-asm.c
|
|
@@ -0,0 +1,48 @@
|
|
+/* -Woverlength-strings complains about string constants which are too long
|
|
+ for the C standard's "minimum maximum" limits. It is off by default,
|
|
+ but implied by -pedantic. */
|
|
+
|
|
+/* { dg-options "-std=c90 -pedantic" } */
|
|
+
|
|
+#define TEN " "
|
|
+#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
|
|
+#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
|
|
+
|
|
+/* C89's minimum-maximum is 509. */
|
|
+__asm__ (HUN HUN HUN HUN HUN TEN);
|
|
+
|
|
+/* C99's minimum-maximum is 4095. */
|
|
+__asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456");
|
|
+
|
|
+void
|
|
+f (void)
|
|
+{
|
|
+ /* C89's minimum-maximum is 509. */
|
|
+ __asm__ (HUN HUN HUN HUN HUN TEN);
|
|
+ __asm__ (HUN HUN HUN HUN HUN TEN : :);
|
|
+ __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label);
|
|
+
|
|
+ /* C99's minimum-maximum is 4095. */
|
|
+ __asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456");
|
|
+ __asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456" : :);
|
|
+ __asm__ goto (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456" : : : : label);
|
|
+
|
|
+ label: ;
|
|
+}
|
|
+
|
|
--- gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-asm.c
|
|
+++ gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-asm.c
|
|
@@ -0,0 +1,48 @@
|
|
+/* -Woverlength-strings complains about string constants which are too long
|
|
+ for the C standard's "minimum maximum" limits. It is off by default,
|
|
+ but implied by -pedantic. */
|
|
+
|
|
+/* { dg-options "-std=c99 -pedantic" } */
|
|
+
|
|
+#define TEN " "
|
|
+#define HUN TEN TEN TEN TEN TEN TEN TEN TEN TEN TEN
|
|
+#define THO HUN HUN HUN HUN HUN HUN HUN HUN HUN HUN
|
|
+
|
|
+/* C89's minimum-maximum is 509. */
|
|
+__asm__ (HUN HUN HUN HUN HUN TEN);
|
|
+
|
|
+/* C99's minimum-maximum is 4095. */
|
|
+__asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456");
|
|
+
|
|
+void
|
|
+f (void)
|
|
+{
|
|
+ /* C89's minimum-maximum is 509. */
|
|
+ __asm__ (HUN HUN HUN HUN HUN TEN);
|
|
+ __asm__ (HUN HUN HUN HUN HUN TEN : :);
|
|
+ __asm__ goto (HUN HUN HUN HUN HUN TEN : : : : label);
|
|
+
|
|
+ /* C99's minimum-maximum is 4095. */
|
|
+ __asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456");
|
|
+ __asm__ (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456" : :);
|
|
+ __asm__ goto (
|
|
+ THO THO THO THO /* 4000 */
|
|
+ TEN TEN TEN TEN TEN /* 4050 */
|
|
+ TEN TEN TEN TEN /* 4090 */
|
|
+ "123456" : : : : label);
|
|
+
|
|
+ label: ;
|
|
+}
|
|
+
|