From 0f38b8114265421f93d37b835f1eb509c0f46247 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 8 Jun 2001 22:33:46 +0000 Subject: [PATCH] c-decl.c (grokdeclarator): Make the TREE_TYPE for declarations accurately reflect its cv-qualification. * c-decl.c (grokdeclarator): Make the TREE_TYPE for declarations accurately reflect its cv-qualification. * c-typeck.c (type_lists_compatible_p): Ignore the top-levl cv-qualifiers on function types. From-SVN: r43056 --- gcc/ChangeLog | 7 +++++++ gcc/c-decl.c | 10 ++++++++-- gcc/c-typeck.c | 3 ++- gcc/testsuite/gcc.c-torture/compile/920729-1.c | 2 +- gcc/testsuite/gcc.c-torture/execute/931018-1.c | 2 +- gcc/testsuite/gcc.dg/noncompile/redecl-1.c | 4 ++-- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e6f8e986f64..7fcaca4e39c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2001-06-08 Mark Mitchell + + * c-decl.c (grokdeclarator): Make the TREE_TYPE for declarations + accurately reflect its cv-qualification. + * c-typeck.c (type_lists_compatible_p): Ignore the top-levl + cv-qualifiers on function types. + 2001-06-08 Mark Mitchell * basic-block.h: Improve comments. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 378b53e355f..78c852e214f 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4719,7 +4719,7 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) if (decl_context == PARM) { - tree type_as_written = type; + tree type_as_written; tree promoted_type; /* A parameter declared as an array of T is really a pointer to T. @@ -4782,6 +4782,10 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) type = build_pointer_type (type); type_quals = TYPE_UNQUALIFIED; } + else if (type_quals) + type = c_build_qualified_type (type, type_quals); + + type_as_written = type; decl = build_decl (PARM_DECL, declarator, type); if (size_varies) @@ -4908,7 +4912,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized) type_quals = TYPE_UNQUALIFIED; #endif } - + else if (type_quals) + type = c_build_qualified_type (type, type_quals); + decl = build_decl (VAR_DECL, declarator, type); if (size_varies) C_DECL_VARIABLE_SIZE (decl) = 1; diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index 478ec43544b..5653ae59b68 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -651,7 +651,8 @@ type_lists_compatible_p (args1, args2) if (simple_type_promotes_to (TREE_VALUE (args1)) != NULL_TREE) return 0; } - else if (! (newval = comptypes (TREE_VALUE (args1), TREE_VALUE (args2)))) + else if (! (newval = comptypes (TYPE_MAIN_VARIANT (TREE_VALUE (args1)), + TYPE_MAIN_VARIANT (TREE_VALUE (args2))))) { /* Allow wait (union {union wait *u; int *i} *) and wait (union wait *) to be compatible. */ diff --git a/gcc/testsuite/gcc.c-torture/compile/920729-1.c b/gcc/testsuite/gcc.c-torture/compile/920729-1.c index 96676e95307..de00be5af88 100644 --- a/gcc/testsuite/gcc.c-torture/compile/920729-1.c +++ b/gcc/testsuite/gcc.c-torture/compile/920729-1.c @@ -1,2 +1,2 @@ -extern int i;extern volatile int i; +extern volatile int i; f(){int j;for(;;)j = i;} diff --git a/gcc/testsuite/gcc.c-torture/execute/931018-1.c b/gcc/testsuite/gcc.c-torture/execute/931018-1.c index d3814e699b8..01b6050bf35 100644 --- a/gcc/testsuite/gcc.c-torture/execute/931018-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/931018-1.c @@ -1,5 +1,5 @@ unsigned int a[0x1000]; -extern unsigned long v; +extern const unsigned long v; main () { diff --git a/gcc/testsuite/gcc.dg/noncompile/redecl-1.c b/gcc/testsuite/gcc.dg/noncompile/redecl-1.c index 65b06369ddb..f4db95013e2 100644 --- a/gcc/testsuite/gcc.dg/noncompile/redecl-1.c +++ b/gcc/testsuite/gcc.dg/noncompile/redecl-1.c @@ -4,7 +4,7 @@ int foo () { - int bar; /* { dg-error "previously declared" "previously declared" } */ - volatile int bar; /* { dg-error "redeclaration" "redeclaration" } */ + int bar; /* { dg-error "previous.*decl" "previous.*decl" } */ + volatile int bar; /* { dg-error "conflicting types" "conflicting types" } */ }