Commit 46097c76 by Joseph Myers Committed by Joseph Myers

re PR c/16666 (dremf type conflict)

	PR c/16666
	* c-decl.c (start_function): Don't check for DECL_BUILT_IN when
	determining whether to copy parameter types from a previous
	prototype declaration.

testsuite:
	* gcc.dg/dremf-type-compat-1.c, gcc.dg/dremf-type-compat-2.c,
	gcc.dg/dremf-type-compat-3.c, gcc.dg/dremf-type-compat-4.c,
	gcc.dg/old-style-prom-1.c, gcc.dg/old-style-prom-2.c,
	gcc.dg/old-style-prom-3.c: New tests.

From-SVN: r89883
parent 514a3b11
2004-10-30 Joseph S. Myers <joseph@codesourcery.com>
PR c/16666
* c-decl.c (start_function): Don't check for DECL_BUILT_IN when
determining whether to copy parameter types from a previous
prototype declaration.
2004-10-29 Roger Sayle <roger@eyesopen.com>
PR rtl-optimization/17581
......
......@@ -5698,11 +5698,9 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
DECL_INITIAL (decl1) = error_mark_node;
/* If this definition isn't a prototype and we had a prototype declaration
before, copy the arg type info from that prototype.
But not if what we had before was a builtin function. */
before, copy the arg type info from that prototype. */
old_decl = lookup_name_in_scope (DECL_NAME (decl1), current_scope);
if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE
&& !DECL_BUILT_IN (old_decl)
&& comptypes (TREE_TYPE (TREE_TYPE (decl1)),
TREE_TYPE (TREE_TYPE (old_decl)))
&& TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0)
......
2004-10-30 Joseph S. Myers <joseph@codesourcery.com>
PR c/16666
* gcc.dg/dremf-type-compat-1.c, gcc.dg/dremf-type-compat-2.c,
gcc.dg/dremf-type-compat-3.c, gcc.dg/dremf-type-compat-4.c,
gcc.dg/old-style-prom-1.c, gcc.dg/old-style-prom-2.c,
gcc.dg/old-style-prom-3.c: New tests.
2004-10-30 Danny Smith <dannysmith@users.sourceforge.net>
* gcc.dg/bf-ms-attrib.c: Add protototype for abort.
......
/* Test for bogus diagnostics for dremf definition. Although this
definition is formally incorrect in ISO C, a GNU extension permits
a prototype followed by unpromoted types in a function definition,
so it should be permitted when the function is built in. Bug
16666. */
/* { dg-do compile } */
/* { dg-options "" } */
float dremf (float, float);
float
dremf (x, y)
float x, y;
{
return x + y;
}
/* Test for bogus diagnostics for dremf definition. Although this
definition is formally incorrect in ISO C, a GNU extension permits
a prototype followed by unpromoted types in a function definition,
so it should be permitted when the function is built in. Bug
16666. Test with -pedantic, where the problem should still be
diagnosed. */
/* { dg-do compile } */
/* { dg-options "-pedantic" } */
float dremf (float, float); /* { dg-warning "warning: prototype declaration" } */
float
dremf (x, y)
float x;
float y;
{ /* { dg-warning "warning: promoted argument '.' doesn't match prototype" } */
return x + y;
}
/* Test for bogus diagnostics for dremf definition. Although this
definition is formally incorrect in ISO C, a GNU extension permits
a prototype followed by unpromoted types in a function definition,
so it should be permitted when the function is built in. Bug
16666. Test with -pedantic-errors, where the problem should still
be diagnosed. */
/* { dg-do compile } */
/* { dg-options "-pedantic-errors" } */
float dremf (float, float); /* { dg-error "error: prototype declaration" } */
float
dremf (x, y)
float x;
float y;
{ /* { dg-error "error: promoted argument '.' doesn't match prototype" } */
return x + y;
}
/* Test for bogus diagnostics for dremf definition, as in bug 16666.
The GNU extension permitting a prototype to override the promotion
of old-style parameter declarations should only apply when the
prototype is visible, not for a built-in prototype. */
/* { dg-do compile } */
/* { dg-options "" } */
float
dremf(x, y)
float x, y; /* { dg-warning "warning: conflicting types for built-in function 'dremf'" } */
{
return x + y;
}
/* Test for prototype followed by old-style definition, as in
dremf-type-compat-1.c but with a non-built-in function. */
/* { dg-do compile } */
/* { dg-options "" } */
float f (float, float);
float
f (x, y)
float x, y;
{
return x + y;
}
/* Test for prototype followed by old-style definition, as in
dremf-type-compat-2.c but with a non-built-in function. */
/* { dg-do compile } */
/* { dg-options "-pedantic" } */
float f (float, float); /* { dg-warning "warning: prototype declaration" } */
float
f (x, y)
float x;
float y;
{ /* { dg-warning "warning: promoted argument '.' doesn't match prototype" } */
return x + y;
}
/* Test for prototype followed by old-style definition, as in
dremf-type-compat-3.c but with a non-built-in function. */
/* { dg-do compile } */
/* { dg-options "-pedantic-errors" } */
float f (float, float); /* { dg-error "error: prototype declaration" } */
float
f (x, y)
float x;
float y;
{ /* { dg-error "error: promoted argument '.' doesn't match prototype" } */
return x + y;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment