decl2.c (mark_used): Set the source location of the used decl to the current input...
authorAlexandre Oliva <aoliva@redhat.com>
Tue, 15 Feb 2005 19:37:13 +0000 (19:37 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 15 Feb 2005 19:37:13 +0000 (19:37 +0000)
* decl2.c (mark_used): Set the source location of the used decl to
the current input location here...
* method.c (synthesize_method): ... not here.  Set input_location
from the decl instead.

From-SVN: r95070

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/cp/method.c

index b8f356f..3375ed0 100644 (file)
@@ -1,3 +1,10 @@
+2005-02-15  Alexandre Oliva  <aoliva@redhat.com>
+
+       * decl2.c (mark_used): Set the source location of the used decl to
+       the current input location here...
+       * method.c (synthesize_method): ... not here.  Set input_location
+       from the decl instead.
+
 2005-02-14  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/19608
index 0a74ed7..c7b0415 100644 (file)
@@ -3161,9 +3161,20 @@ mark_used (tree decl)
       && DECL_ARTIFICIAL (decl) 
       && !DECL_THUNK_P (decl)
       && ! DECL_INITIAL (decl)
-      /* Kludge: don't synthesize for default args.  */
+      /* Kludge: don't synthesize for default args.  Unfortunately this
+        rules out initializers of namespace-scoped objects too, but
+        it's sort-of ok if the implicit ctor or dtor decl keeps
+        pointing to the class location.  */
       && current_function_decl)
     {
+      /* Put the function definition at the position where it is needed,
+        rather than within the body of the class.  That way, an error
+        during the generation of the implicit body points at the place
+        where the attempt to generate the function occurs, giving the
+        user a hint as to why we are attempting to generate the
+        function.  */
+      DECL_SOURCE_LOCATION (decl) = input_location;
+
       synthesize_method (decl);
       /* If we've already synthesized the method we don't need to
         instantiate it, so we can return right away.  */
index fadbf39..85e2b3f 100644 (file)
@@ -705,12 +705,15 @@ synthesize_method (tree fndecl)
   tree context = decl_function_context (fndecl);
   bool need_body = true;
   tree stmt;
+  location_t save_input_location = input_location;
 
   /* If we've been asked to synthesize a clone, just synthesize the
      cloned function instead.  Doing so will automatically fill in the
      body for the clone.  */
   if (DECL_CLONED_FUNCTION_P (fndecl))
     {
+      DECL_SOURCE_LOCATION (DECL_CLONED_FUNCTION (fndecl)) =
+       DECL_SOURCE_LOCATION (fndecl);
       synthesize_method (DECL_CLONED_FUNCTION (fndecl));
       return;
     }
@@ -724,13 +727,7 @@ synthesize_method (tree fndecl)
   else if (nested)
     push_function_context_to (context);
 
-  /* Put the function definition at the position where it is needed,
-     rather than within the body of the class.  That way, an error
-     during the generation of the implicit body points at the place
-     where the attempt to generate the function occurs, giving the
-     user a hint as to why we are attempting to generate the
-     function.  */
-  DECL_SOURCE_LOCATION (fndecl) = input_location;
+  input_location = DECL_SOURCE_LOCATION (fndecl);
 
   start_preparsed_function (fndecl, NULL_TREE, SF_DEFAULT | SF_PRE_PARSED);
   stmt = begin_function_body ();
@@ -761,6 +758,8 @@ synthesize_method (tree fndecl)
   finish_function_body (stmt);
   expand_or_defer_fn (finish_function (0));
 
+  input_location = save_input_location;
+
   if (! context)
     pop_from_top_level ();
   else if (nested)