diff options
| author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-21 23:46:20 +0000 |
|---|---|---|
| committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-07-21 23:46:20 +0000 |
| commit | 3ad5f027d89dd828eff822371e1791f520d83c41 (patch) | |
| tree | 3445b1b5b70b8f6f28f797b70463fa6e393fa8e1 /gcc/testsuite/gcc.dg/init-string-1.c | |
| parent | e2e173ac79124b41dd69b8f1323782aee89ac789 (diff) | |
| download | ppe42-gcc-3ad5f027d89dd828eff822371e1791f520d83c41.tar.gz ppe42-gcc-3ad5f027d89dd828eff822371e1791f520d83c41.zip | |
PR c/11250
* c-parse.in (init): Change to exprtype.
(primary): Set original_code for STRING to STRING_CST.
Call maybe_warn_string_init for compound literals.
(initdcl, notype_initdcl): Call maybe_warn_string_init.
(initval): Update.
* c-tree.h (maybe_warn_string_init): New.
(pop_init_level, process_init_element): Use struct c_expr.
(struct c_expr): Update comment.
* c-typeck.c (maybe_warn_string_init): New function.
(digest_init): Call it. Additional parameter strict_string. All
callers changed.
(output_init_element): Likewise.
(struct constructor_stack): Use struct c_expr for
replacement_value.
(really_start_incremental_init, push_init_level): Update.
(pop_init_level): Update. Return struct c_expr.
(process_init_level): Update. Take struct c_expr argument.
testsuite:
* gcc.dg/init-string-1.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85022 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/init-string-1.c')
| -rw-r--r-- | gcc/testsuite/gcc.dg/init-string-1.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/init-string-1.c b/gcc/testsuite/gcc.dg/init-string-1.c new file mode 100644 index 00000000000..ace3b34562e --- /dev/null +++ b/gcc/testsuite/gcc.dg/init-string-1.c @@ -0,0 +1,59 @@ +/* String initializers for arrays must not be parenthesized. Bug + 11250 from h.b.furuseth at usit.uio.no. */ +/* Origin: Joseph Myers <jsm@polyomino.org.uk> */ +/* { dg-do compile } */ +/* { dg-options "-std=c99 -pedantic-errors" } */ + +#include <stddef.h> + +char *a = "a"; +char *b = ("b"); +char *c = (("c")); + +char d[] = "d"; +char e[] = ("e"); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 14 } */ +char f[] = (("f")); /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 16 } */ + +signed char g[] = { "d" }; +unsigned char h[] = { ("e") }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 20 } */ +signed char i[] = { (("f")) }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 22 } */ + + +struct s { char a[10]; int b; wchar_t c[10]; }; + +struct s j = { + "j", + 1, + (L"j") +}; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 32 } */ +struct s k = { + (("k")), /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 35 } */ + 1, + L"k" +}; + +struct s l = { + .c = (L"l"), /* { dg-bogus "warning" "warning in place of error" } */ + /* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 42 } */ + .a = "l" +}; + +struct s m = { + .c = L"m", + .a = ("m") +}; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 50 } */ + +char *n = (char []){ "n" }; + +char *o = (char []){ ("o") }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 55 } */ + +wchar_t *p = (wchar_t [5]){ (L"p") }; /* { dg-bogus "warning" "warning in place of error" } */ +/* { dg-error "parenthesized|near init" "paren array" { target *-*-* } 58 } */ |

