OSDN Git Service

2003-06-10 Andrew Haley <aph@redhat.com>
[pf3gnuchains/gcc-fork.git] / gcc / c-common.c
index 4ebddbd..d194012 100644 (file)
@@ -41,7 +41,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "target.h"
 #include "langhooks.h"
 #include "tree-inline.h"
-
+#include "c-tree.h"
 
 cpp_reader *parse_in;          /* Declared in c-pragma.h.  */
 
@@ -264,13 +264,6 @@ int flag_no_asm;
 
 int flag_const_strings;
 
-/* Nonzero means `$' can be in an identifier.  */
-
-#ifndef DOLLARS_IN_IDENTIFIERS
-#define DOLLARS_IN_IDENTIFIERS 1
-#endif
-int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
-
 /* Nonzero means to treat bitfields as signed unless they say `unsigned'.  */
 
 int flag_signed_bitfields = 1;
@@ -304,9 +297,10 @@ int warn_parentheses;
 int warn_missing_braces;
 
 /* Warn about comparison of signed and unsigned values.
-   If -1, neither -Wsign-compare nor -Wno-sign-compare has been specified.  */
+   If -1, neither -Wsign-compare nor -Wno-sign-compare has been specified
+   (in which case -Wextra gets to decide).  */
 
-int warn_sign_compare;
+int warn_sign_compare = -1;
 
 /* Nonzero means warn about usage of long long when `-pedantic'.  */
 
@@ -618,6 +612,10 @@ int flag_abi_version = 1;
 
 int warn_abi = 0;
 
+/* Nonzero means warn about invalid uses of offsetof. */
+int warn_invalid_offsetof = 1;
+
 /* Nonzero means warn about implicit declarations.  */
 
 int warn_implicit = 1;
@@ -625,7 +623,7 @@ int warn_implicit = 1;
 /* Nonzero means warn when all ctors or dtors are private, and the class
    has no friends.  */
 
-int warn_ctor_dtor_privacy = 1;
+int warn_ctor_dtor_privacy = 0;
 
 /* Nonzero means warn in function declared in derived class has the
    same name as a virtual in the base class, but fails to match the
@@ -794,6 +792,8 @@ static tree handle_nonnull_attribute        PARAMS ((tree *, tree, tree, int,
                                                 bool *));
 static tree handle_nothrow_attribute   PARAMS ((tree *, tree, tree, int,
                                                 bool *));
+static tree handle_cleanup_attribute   PARAMS ((tree *, tree, tree, int,
+                                                bool *));
 static tree vector_size_helper PARAMS ((tree, tree));
 
 static void check_function_nonnull     PARAMS ((tree, tree));
@@ -870,6 +870,8 @@ const struct attribute_spec c_common_attribute_table[] =
   { "nothrow",                0, 0, true,  false, false,
                              handle_nothrow_attribute },
   { "may_alias",             0, 0, false, true, false, NULL },
+  { "cleanup",               1, 1, true, false, false,
+                             handle_cleanup_attribute },
   { NULL,                     0, 0, false, false, false, NULL }
 };
 
@@ -918,8 +920,7 @@ c_expand_start_cond (cond, compstmt_count, if_stmt)
 
   /* Record this if statement.  */
   if_stack[if_stack_pointer].compstmt_count = compstmt_count;
-  if_stack[if_stack_pointer].locus.file = input_filename;
-  if_stack[if_stack_pointer].locus.line = lineno;
+  if_stack[if_stack_pointer].locus = input_location;
   if_stack[if_stack_pointer].needs_warning = 0;
   if_stack[if_stack_pointer].if_stmt = if_stmt;
   if_stack_pointer++;
@@ -1158,8 +1159,8 @@ fname_decl (rid, id)
         beginning of the function and this line number will be wrong.
         To avoid this problem set the lineno to 0 here; that prevents
         it from appearing in the RTL.  */
-      int saved_lineno = lineno;
-      lineno = 0;
+      int saved_lineno = input_line;
+      input_line = 0;
       
       decl = (*make_fname_decl) (id, fname_vars[ix].pretty);
       if (last_tree != saved_last_tree)
@@ -1175,7 +1176,7 @@ fname_decl (rid, id)
                                                 saved_function_name_decls);
        }
       *fname_vars[ix].decl = decl;
-      lineno = saved_lineno;
+      input_line = saved_lineno;
     }
   if (!ix && !current_function_decl)
     pedwarn_with_decl (decl, "`%s' is not defined outside of function scope");
@@ -6096,6 +6097,55 @@ handle_nothrow_attribute (node, name, args, flags, no_add_attrs)
 
   return NULL_TREE;
 }
+
+/* Handle a "cleanup" attribute; arguments as in
+   struct attribute_spec.handler.  */
+
+static tree
+handle_cleanup_attribute (node, name, args, flags, no_add_attrs)
+     tree *node;
+     tree name;
+     tree args;
+     int flags ATTRIBUTE_UNUSED;
+     bool *no_add_attrs;
+{
+  tree decl = *node;
+  tree cleanup_id, cleanup_decl;
+
+  /* ??? Could perhaps support cleanups on TREE_STATIC, much like we do
+     for global destructors in C++.  This requires infrastructure that
+     we don't have generically at the moment.  It's also not a feature
+     we'd be missing too much, since we do have attribute constructor.  */
+  if (TREE_CODE (decl) != VAR_DECL || TREE_STATIC (decl))
+    {
+      warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
+      *no_add_attrs = true;
+      return NULL_TREE;
+    }
+
+  /* Verify that the argument is a function in scope.  */
+  /* ??? We could support pointers to functions here as well, if
+     that was considered desirable.  */
+  cleanup_id = TREE_VALUE (args);
+  if (TREE_CODE (cleanup_id) != IDENTIFIER_NODE)
+    {
+      error ("cleanup arg not an identifier");
+      *no_add_attrs = true;
+      return NULL_TREE;
+    }
+  cleanup_decl = lookup_name (cleanup_id);
+  if (!cleanup_decl || TREE_CODE (cleanup_decl) != FUNCTION_DECL)
+    {
+      error ("cleanup arg not a function");
+      *no_add_attrs = true;
+      return NULL_TREE;
+    }
+
+  /* That the function has proper type is checked with the 
+     eventual call to build_function_call.  */
+
+  return NULL_TREE;
+}
 \f
 /* Check for valid arguments being passed to a function.  */
 void