From 87f9e23dafd42a3ad8df6feb6cc413e3aa6f110b Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 14 Mar 2011 18:01:10 +0000 Subject: [PATCH] c-parser.c (c_parser_asm_string_literal): Clear warn_overlength_strings. gcc * c-parser.c (c_parser_asm_string_literal): Clear warn_overlength_strings. gcc/testsuite * 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. From-SVN: r170948 --- gcc/ChangeLog | 5 ++ gcc/c-parser.c | 3 ++ gcc/testsuite/ChangeLog | 6 +++ .../Woverlength-strings-pedantic-c89-asm.c | 47 ++++++++++++++++++ .../Woverlength-strings-pedantic-c90-asm.c | 48 +++++++++++++++++++ .../Woverlength-strings-pedantic-c99-asm.c | 48 +++++++++++++++++++ 6 files changed, 157 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-asm.c create mode 100644 gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-asm.c create mode 100644 gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-asm.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f1a353c00fb..07aa11916bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-03-14 Tom Tromey + + * c-parser.c (c_parser_asm_string_literal): Clear + warn_overlength_strings. + 2011-03-14 Tom Tromey * c-parser.c (disable_extension_diagnostics): Save diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 7b18827cfc6..33e7362baa0 100644 --- a/gcc/c-parser.c +++ b/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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6afb96daadc..be3157c2227 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-03-14 Tom Tromey + + * 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. + 2011-03-14 Tom Tromey * gcc.dg/Woverlength-strings-pedantic-c89-ext.c: New file. diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-asm.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c89-asm.c new file mode 100644 index 00000000000..45373bc1a98 --- /dev/null +++ b/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: ; +} diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-asm.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c90-asm.c new file mode 100644 index 00000000000..b5523bc8906 --- /dev/null +++ b/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: ; +} + diff --git a/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-asm.c b/gcc/testsuite/gcc.dg/Woverlength-strings-pedantic-c99-asm.c new file mode 100644 index 00000000000..8840e38bdc4 --- /dev/null +++ b/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: ; +} + -- 2.30.2