re PR c/53532 (function call ignored when called with argument of incompatible, undefined structure)
PR c/53532 PR c/51034 PR c/53196 * c-decl.c (build_compound_literal): Call c_incomplete_type_error if type isn't complete. * gcc.dg/pr53532.c: New test. * gcc.dg/c99-complit-2.c: Add two new dg-error directives, adjust line numbers. * gcc.dg/noncompile/950825-1.c: Expect incomplete type error message. * gcc.dg/Wcxx-compat-8.c: Likewise. * gcc.dg/pr51034.c: New test. * gcc.dg/pr53196-1.c: New test. * gcc.dg/pr53196-2.c: New test. From-SVN: r188483
This commit is contained in:
parent
9690ac05c9
commit
cce5086157
|
@ -1,3 +1,11 @@
|
|||
2012-06-12 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c/53532
|
||||
PR c/51034
|
||||
PR c/53196
|
||||
* c-decl.c (build_compound_literal): Call c_incomplete_type_error
|
||||
if type isn't complete.
|
||||
|
||||
2012-06-12 Uros Bizjak <ubizjak@gmail.com>
|
||||
|
||||
* config/ia64/sync.md (fetchop_name): Change ior attribute to "or".
|
||||
|
|
|
@ -4637,7 +4637,10 @@ build_compound_literal (location_t loc, tree type, tree init, bool non_const)
|
|||
}
|
||||
|
||||
if (type == error_mark_node || !COMPLETE_TYPE_P (type))
|
||||
return error_mark_node;
|
||||
{
|
||||
c_incomplete_type_error (NULL_TREE, type);
|
||||
return error_mark_node;
|
||||
}
|
||||
|
||||
stmt = build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl);
|
||||
complit = build1 (COMPOUND_LITERAL_EXPR, type, stmt);
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
2012-06-12 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c/53532
|
||||
PR c/51034
|
||||
PR c/53196
|
||||
* gcc.dg/pr53532.c: New test.
|
||||
* gcc.dg/c99-complit-2.c: Add two new dg-error directives,
|
||||
adjust line numbers.
|
||||
* gcc.dg/noncompile/950825-1.c: Expect incomplete type error message.
|
||||
* gcc.dg/Wcxx-compat-8.c: Likewise.
|
||||
* gcc.dg/pr51034.c: New test.
|
||||
* gcc.dg/pr53196-1.c: New test.
|
||||
* gcc.dg/pr53196-2.c: New test.
|
||||
|
||||
2012-06-12 Janis Johnson <janisjo@codesourcery.com>
|
||||
|
||||
* gcc.dg/torture/stackalign/stackalign.exp: Combine stack
|
||||
|
|
|
@ -63,3 +63,5 @@ f5 ()
|
|||
{
|
||||
return &((struct t8) { }); /* { dg-warning "invalid in C\[+\]\[+\]" } */
|
||||
}
|
||||
|
||||
/* { dg-error "invalid use of undefined type" "" { target *-*-* } 64 } */
|
||||
|
|
|
@ -18,45 +18,47 @@ foo (int a)
|
|||
/* { dg-error "init" "void type" { target *-*-* } 17 } */
|
||||
&(struct si) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "incomplete struct type" { target *-*-* } 19 } */
|
||||
/* { dg-error "invalid use of undefined type" "" { target *-*-* } 19 } */
|
||||
&(union ui) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "incomplete union type" { target *-*-* } 21 } */
|
||||
/* { dg-error "init" "incomplete union type" { target *-*-* } 22 } */
|
||||
/* { dg-error "invalid use of undefined type" "" { target *-*-* } 22 } */
|
||||
(void (void)) { 0 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "function type" { target *-*-* } 23 } */
|
||||
/* { dg-error "init" "function type" { target *-*-* } 25 } */
|
||||
(int [a]) { 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init|variable" "VLA type" { target *-*-* } 25 } */
|
||||
/* { dg-error "init|variable" "VLA type" { target *-*-* } 27 } */
|
||||
/* Initializers must not attempt to initialize outside the object
|
||||
declared. */
|
||||
(int [1]) { [1] = 2 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "value outside array" { target *-*-* } 29 } */
|
||||
(int [1]) { [-1] = 2 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "value outside array" { target *-*-* } 31 } */
|
||||
(int [1]) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
(int [1]) { [-1] = 2 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "value outside array" { target *-*-* } 33 } */
|
||||
(int [1]) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "value outside array" { target *-*-* } 35 } */
|
||||
}
|
||||
|
||||
int z;
|
||||
|
||||
/* Outside a function, initializers must be constant. */
|
||||
struct s *s0 = &(struct s) { 0, z }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "non-const" { target *-*-* } 40 } */
|
||||
int sz = sizeof((struct s) { 0, z }); /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "non-const" { target *-*-* } 42 } */
|
||||
int sz = sizeof((struct s) { 0, z }); /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "non-const" { target *-*-* } 44 } */
|
||||
|
||||
/* Compound literals aren't themselves constant expressions. */
|
||||
int x = (int) { 0 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "non-const" { target *-*-* } 46 } */
|
||||
/* { dg-error "init" "non-const" { target *-*-* } 48 } */
|
||||
|
||||
/* Nor are they suitable structure or union initializers
|
||||
outside a function. */
|
||||
struct s s1 = (struct s) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "struct bad init" { target *-*-* } 51 } */
|
||||
/* { dg-error "init" "struct bad init" { target *-*-* } 53 } */
|
||||
union u u1 = (union u) { 0 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "union bad init" { target *-*-* } 53 } */
|
||||
/* { dg-error "init" "union bad init" { target *-*-* } 55 } */
|
||||
|
||||
/* They aren't suitable for array initializers, either inside or outside
|
||||
a function. */
|
||||
int y[2] = (int [2]) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "array bad init" { target *-*-* } 58 } */
|
||||
/* { dg-error "init" "array bad init" { target *-*-* } 60 } */
|
||||
|
||||
void
|
||||
bar (void)
|
||||
|
@ -64,5 +66,5 @@ bar (void)
|
|||
struct s s2 = (struct s) { 0, 1 };
|
||||
union u u2 = (union u) { 0 };
|
||||
int z[2] = (int [2]) { 0, 1 }; /* { dg-bogus "warning" "warning in place of error" } */
|
||||
/* { dg-error "init" "array bad init" { target *-*-* } 66 } */
|
||||
/* { dg-error "init" "array bad init" { target *-*-* } 68 } */
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
main()
|
||||
{
|
||||
return (struct x) {{y: 0}}; /* { dg-error "extra|near|excess|incompatible" } */
|
||||
return (struct x) {{y: 0}}; /* { dg-error "extra|near|excess|incompatible|invalid" } */
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
/* PR c/51034 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=gnu99" } */
|
||||
|
||||
struct S;
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
struct R { typeof (((struct W) {})) x; } r; /* { dg-error "invalid use of undefined type" } */
|
||||
struct S { typeof (((struct S) {})) x; } s; /* { dg-error "invalid use of undefined type" } */
|
||||
struct T { int x[sizeof ((struct T) {})]; } t;/* { dg-error "invalid use of undefined type" } */
|
||||
struct U { int x[sizeof((struct V){})];} u; /* { dg-error "invalid use of undefined type" } */
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
/* PR c/53196 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=gnu99" } */
|
||||
|
||||
extern int printf (const char *, ...);
|
||||
struct foo { int i; };
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
struct foo f = (struct foo_typo) { }; /* { dg-error "invalid use of undefined type" } */
|
||||
printf ("%d\n", f.i);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
/* PR c/53196 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-std=c99 -pedantic-errors" } */
|
||||
|
||||
extern int printf (const char *, ...);
|
||||
struct foo { int i; };
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
struct foo f = (struct foo_typo) { }; /* { dg-error "invalid use of undefined type" } */
|
||||
printf ("%d\n", f.i);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* { dg-error "ISO C forbids empty initializer braces" "" { target *-*-* } 11 } */
|
|
@ -0,0 +1,13 @@
|
|||
/* PR c/53532 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "" } */
|
||||
|
||||
struct S {};
|
||||
extern int foo (struct S);
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
foo ((struct T) {}); /* { dg-error "invalid use of undefined type" } */
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue