c-decl.c (grokdeclarator): Make the TREE_TYPE for declarations accurately reflect...
authorMark Mitchell <mark@codesourcery.com>
Fri, 8 Jun 2001 22:33:46 +0000 (22:33 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 8 Jun 2001 22:33:46 +0000 (22:33 +0000)
* 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
gcc/c-decl.c
gcc/c-typeck.c
gcc/testsuite/gcc.c-torture/compile/920729-1.c
gcc/testsuite/gcc.c-torture/execute/931018-1.c
gcc/testsuite/gcc.dg/noncompile/redecl-1.c

index e6f8e986f643a7d3d3ea6fff6d8c5e7f2c678d3d..7fcaca4e39c0e07d5b00cac549766ca73e99dd47 100644 (file)
@@ -1,3 +1,10 @@
+2001-06-08  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <mark@codesourcery.com>
 
        * basic-block.h: Improve comments.
index 378b53e355f63eaf642b9396daf2703001651218..78c852e214f7de49bfdcbf8fb12be8410fe00091 100644 (file)
@@ -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;
index 478ec43544b056ed47a759ad649352d789bb57a3..5653ae59b68319a81ddc1479d6a185fa053c5b06 100644 (file)
@@ -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.  */
index 96676e953077eef18e2efaf3e476c893e2e739db..de00be5af8865e311da0b3520a61bbc239526a19 100644 (file)
@@ -1,2 +1,2 @@
-extern int i;extern volatile int i;
+extern volatile int i;
 f(){int j;for(;;)j = i;}
index d3814e699b8632bd5da1998ce0c5d72a2027507d..01b6050bf3531933a866512f2f37812223c69754 100644 (file)
@@ -1,5 +1,5 @@
 unsigned int a[0x1000];
-extern unsigned long v;
+extern const unsigned long v;
 
 main ()
 {
index 65b06369ddb16182bc6004cb11664924262e79cf..f4db95013e2c1d8273cb6986071c9a08628351bd 100644 (file)
@@ -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" } */
 }