This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH]: PR c++/18313


Hi, 

The C++ frontend forgets to warn about pointless qualifies on the return type, 
just like the C frontend does. Bootstrapped, regtested on i686-suse-linux. 

Ok for mainline?

2006-10-29  Dirk Mueller  <dmueller@suse.de>

	PR c++/18313
	* decl.c (grokdeclarator): Add warning for pointless
	qualifiers on return types.

        * g++.dg/warn/Wreturn-type-4.C: New testcase.

--- cp/decl.c
+++ cp/decl.c
@@ -7524,9 +7525,14 @@ grokdeclarator (const cp_declarator *dec
 	    /* Declaring a function type.
 	       Make sure we have a valid type for the function to return.  */
 
-	    /* We now know that the TYPE_QUALS don't apply to the
-	       decl, but to its return type.  */
-	    type_quals = TYPE_UNQUALIFIED;
+	    if (type_quals != TYPE_UNQUALIFIED)
+	      {
+	        warning (OPT_Wreturn_type,
+			 "type qualifiers ignored on function return type");
+		/* We now know that the TYPE_QUALS don't apply to the
+		   decl, but to its return type.  */
+		type_quals = TYPE_UNQUALIFIED;
+	      }
 
 	    /* Warn about some types functions can't return.  */
 
--- g++.dg/warn/Wreturn-type-4.C
+++ g++.dg/warn/Wreturn-type-4.C
@@ -0,0 +1,10 @@
+/* PR c++/18313 */
+/* { dg-do compile } */
+/* { dg-options "-Wreturn-type" } */
+
+volatile void bar(); /* { dg-warning "type qualifiers ignored" } */
+
+struct A
+{
+    const int bla(); /* { dg-warning "type qualifiers ignored" } */
+};


Dirk


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]