tree.c (cp_build_qualified_type): Don't allow qualified function types.
authorMark Mitchell <mark@codesourcery.com>
Wed, 19 May 1999 04:32:46 +0000 (04:32 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 19 May 1999 04:32:46 +0000 (04:32 +0000)
* tree.c (cp_build_qualified_type): Don't allow qualified function
types.

From-SVN: r27021

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.old-deja/g++.jason/report.C
gcc/testsuite/g++.old-deja/g++.other/qual1.C [new file with mode: 0644]

index fb8c4a187256ed949dbdb71b44d7ccf5c99cce5b..d3d297a441aa147db69d677bf326693b8cd05f83 100644 (file)
@@ -1,3 +1,8 @@
+1999-05-19  Mark Mitchell  <mark@codesourcery.com>
+
+       * tree.c (cp_build_qualified_type): Don't allow qualified function
+       types.
+
 Wed May 19 02:50:53 1999  Arvind Sankar <arvinds@mit.edu>
 
        * gxxint.texi: Fix typo.
index bf16fe2a0c5ccc53c51f50a4ddaa8b66c66c2f9f..dedfc2ffa74c9983d3f60612406bc43e5465c3e8 100644 (file)
@@ -475,7 +475,13 @@ cp_build_qualified_type (type, type_quals)
       type_quals &= ~TYPE_QUAL_RESTRICT;
     }
 
-  if (TREE_CODE (type) == ARRAY_TYPE)
+  if (type_quals != TYPE_UNQUALIFIED
+      && TREE_CODE (type) == FUNCTION_TYPE)
+    {
+      cp_error ("`%T' cannot be `const'-, `volatile'-, or `restrict'-qualified", type);
+      type_quals = TYPE_UNQUALIFIED;
+    }
+  else if (TREE_CODE (type) == ARRAY_TYPE)
     {
       tree real_main_variant = TYPE_MAIN_VARIANT (type);
 
index d3d3392e451d60bad3ed9b6f2134dfe308905491..e514ae75a6d2857167e9590e56c79f8d5cabfc9f 100644 (file)
@@ -42,7 +42,7 @@ class X{
 };
 
 typedef int const * bart ();
-typedef bart const * const * bar2;
+typedef bart const * const * bar2; // ERROR - qualifiers
 
 bar2 baz (X::Y y)
 {
diff --git a/gcc/testsuite/g++.old-deja/g++.other/qual1.C b/gcc/testsuite/g++.old-deja/g++.other/qual1.C
new file mode 100644 (file)
index 0000000..6120dae
--- /dev/null
@@ -0,0 +1,17 @@
+// Build don't link:
+// Origin: Benjamin Pflugmann <philemon@spin.de>
+// Special g++ Options: -O
+
+typedef const char *(func_type)();
+
+class
+{
+public:
+  func_type *Function;
+  const func_type* function(void) { return Function; } // ERROR - qualifiers
+} action;
+
+void work(const char *source)
+{
+  work( action.function()() );
+}