From 21a8534d32fe34d2ceb26f055b29fc063d0c05b1 Mon Sep 17 00:00:00 2001 From: mmitchel Date: Fri, 8 Jun 2001 22:20:48 +0000 Subject: [PATCH] * 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-3_0-branch@43053 138bc75d-0d04-0410-961f-82ee72b054a4 --- 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 aed0c3307a3..c7150769dd7 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-07 Loren J. Rittle * config/alpha/elf.h (MAKE_DECL_ONE_ONLY): Copy definition diff --git a/gcc/c-decl.c b/gcc/c-decl.c index f32fa5a9936..a99425e4173 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -4674,7 +4674,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. @@ -4699,6 +4699,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) @@ -4825,7 +4829,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 14600fe3a28..87a972a761f 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" } */ } -- 2.11.4.GIT