]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/8503 (strange behaviour of function types)
authorNathan Sidwell <nathan@codesourcery.com>
Thu, 26 Dec 2002 12:58:06 +0000 (12:58 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Thu, 26 Dec 2002 12:58:06 +0000 (12:58 +0000)
cp:
PR c++/8503
Remove DR 295 implementation.
* pt.c (check_cv_quals_for_unify): Disable function & method cases.
* tree.c (cp_build_qualified_type_real): Likewise. Don't warn
about ignoring volatile qualifiers.
testsuite:
* g++.dg/template/qualttp20.C: Adjust expected errors.
* g++.old-deja/g++.jason/report.C: Likewise.
* g++.old-deja/g++.other/qual1.C: Likewise.

From-SVN: r60517

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/qualttp20.C
gcc/testsuite/g++.old-deja/g++.jason/report.C
gcc/testsuite/g++.old-deja/g++.other/qual1.C

index f4c75cf42aa0985b535db3cb185280dcccd59d15..21abdcb7f467fc4f3399ac7d7064d70d535b797e 100644 (file)
@@ -1,3 +1,11 @@
+2002-12-26  Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/8503
+       Remove DR 295 implementation.
+       * pt.c (check_cv_quals_for_unify): Disable function & method cases.
+       * tree.c (cp_build_qualified_type_real): Likewise. Don't warn
+       about ignoring volatile qualifiers.
+
 2002-12-18  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * parse.y (bad_parm): Add missing argument to error function call.
index 22304bd0a91b9d4719911c3ed58c74338b30ae75..b751ad49e74ed4adcbd9234bfe5da2c63f94f522 100644 (file)
@@ -8558,9 +8558,7 @@ check_cv_quals_for_unify (strict, arg, parm)
     {
       /* If the cvr quals of parm will not unify with ARG, they'll be
         ignored in instantiation, so we have to do the same here.  */
-      if (TREE_CODE (arg) == REFERENCE_TYPE
-         || TREE_CODE (arg) == FUNCTION_TYPE
-         || TREE_CODE (arg) == METHOD_TYPE)
+      if (TREE_CODE (arg) == REFERENCE_TYPE)
        parm_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
       if (!POINTER_TYPE_P (arg) &&
          TREE_CODE (arg) != TEMPLATE_TYPE_PARM)
index 65dca00360669e15ba758cbf226432214a17e1d2..cdfa49c4572704c8643e0caadd2a8206bc7849f5 100644 (file)
@@ -536,6 +536,11 @@ cp_build_qualified_type_real (type, type_quals, complain)
 {
   tree result;
   int bad_quals = TYPE_UNQUALIFIED;
+  /* We keep bad function qualifiers separate, so that we can decide
+     whether to implement DR 295 or not. DR 295 break existing code,
+     unfortunately. Remove this variable to implement the defect
+     report.  */
+  int bad_func_quals = TYPE_UNQUALIFIED;
 
   if (type == error_mark_node)
     return type;
@@ -551,6 +556,8 @@ cp_build_qualified_type_real (type, type_quals, complain)
          || TREE_CODE (type) == METHOD_TYPE))
     {
       bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
+      if (TREE_CODE (type) != REFERENCE_TYPE)
+       bad_func_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
       type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
     }
   
@@ -569,21 +576,23 @@ cp_build_qualified_type_real (type, type_quals, complain)
     /*OK*/;
   else if (!(complain & (tf_error | tf_ignore_bad_quals)))
     return error_mark_node;
+  else if (bad_func_quals && !(complain & tf_error))
+    return error_mark_node;
   else
     {
       if (complain & tf_ignore_bad_quals)
        /* We're not going to warn about constifying things that can't
           be constified.  */
        bad_quals &= ~TYPE_QUAL_CONST;
+      bad_quals |= bad_func_quals;
       if (bad_quals)
        {
          tree bad_type = build_qualified_type (ptr_type_node, bad_quals);
  
-         if (!(complain & tf_ignore_bad_quals))
+         if (!(complain & tf_ignore_bad_quals)
+             || bad_func_quals)
            error ("`%V' qualifiers cannot be applied to `%T'",
                   bad_type, type);
-         else if (complain & tf_warning)
-           warning ("ignoring `%V' qualifiers on `%T'", bad_type, type);
        }
     }
   
index e49ad5f4379f23d8d6f9c4f924976f8d412fc60f..cd5fa02cedbc527fa69d7dde46c441ff2fdbb81a 100644 (file)
@@ -1,3 +1,9 @@
+2002-12-26  Nathan Sidwell  <nathan@codesourcery.com>
+
+       * g++.dg/template/qualttp20.C: Adjust expected errors.
+       * g++.old-deja/g++.jason/report.C: Likewise.
+       * g++.old-deja/g++.other/qual1.C: Likewise.
+
 2002-12-21  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * gcc.dg/unroll-1.c: New test.
index 2c6c71445c98f3e3c1fadcb55c4baeafa8941e4f..6c68a3a2a8afc47e3c6d20565923ffd6485d0057 100644 (file)
@@ -16,18 +16,20 @@ struct AS
 template <typename T> struct B1 : T
 {
   typedef typename T::L __restrict__ r;// { dg-error "`__restrict' qualifiers cannot" "" }
-  typedef typename T::myT __restrict__ p;// { dg-warning "ignoring `__restrict'" "" }
-  
-  typedef typename T::myT volatile *myvolatile; // { dg-warning "ignoring `volatile'" "" }
-  typename T::myT volatile *a;    // { dg-warning "ignoring `volatile'" "" }
-  myvolatile b;                         // { dg-bogus "ignoring `volatile'" "" { xfail *-*-* } }
+  typedef typename T::myT __restrict__ p;// { dg-warning "ignoring `__restrict'" "" { xfail *-*-* } }
+
+  // The following are DR 295 dependent
+  typedef typename T::myT volatile *myvolatile; // { dg-error "qualifiers" ""  }
+  typename T::myT volatile *a;    // { dg-error "qualifiers" "" }
+  myvolatile b;                         // { dg-error "qualifiers" "" }
 };
 template <typename T> struct B2 : T
 {
-  typedef typename T::myT const *myconst;
-  typename T::myT const *a;
-  myconst b;
+  // The following are DR 295 dependent
+  typedef typename T::myT const *myconst; // { dg-error "qualifiers" "" }
+  typename T::myT const *a; // { dg-error "qualifiers" "" }
+  myconst b; // { dg-error "qualifiers" "" }
 };
 
 B1<AS> b1;     // { dg-error "instantiated" "" }
-B2<AS> b2;
+B2<AS> b2;      // { dg-error "instantiated" "" }      
index bbc1adaf942dd1f196830d1ab7a4d5819964a879..73adee87c9c44519fd7621ca22aa25ef153eb4ed 100644 (file)
@@ -46,8 +46,9 @@ class X{
 };
 
 typedef int const * bart ();
-typedef bart const * const * bar2; // ok - constifying qualifiers
-typedef bart volatile * const * bar2v; // WARNING - qualifiers
+//The following is DR295 dependant
+typedef bart const * const * bar2; // ERROR - constifying qualifiers
+typedef bart volatile * const * bar2v; // ERROR - qualifiers
 
 bar2 baz (X::Y y)
 {                              // ERROR - in this context
index fa2d33f2ce885987712f0c35345ba1288eb7a8ca..13f9bbe497a2ff5806d79eea4508efb6fab78415 100644 (file)
@@ -10,8 +10,9 @@ class
 {
 public:
   func_type *Function;
-  const func_type* function(void) { return Function; } // ok constifying
-  volatile func_type* functionv(void); // WARNING - qualifier
+  // The following is DR 295 dependent
+  const func_type* function(void) { return Function; } // ERROR - constifying
+  volatile func_type* functionv(void); // ERROR - qualifier
 } action;
 
 void work(const char *source)