[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-patches
Subject:    [PATCH]: PR c++/18313
From:       Dirk Mueller <dmuell () gmx ! net>
Date:       2006-10-28 23:30:57
Message-ID: 200610290130.57879.dmuell () gmx ! net
[Download RAW message or body]


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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic