aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl2.c
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2005-06-02 17:52:28 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2005-06-02 17:52:28 +0000
commit3e3935a94ce8702a788cd3e76eab584ed09277e8 (patch)
treea0248ab483fa16d5d61e52a91d59af7f8fbedf6f /gcc/cp/decl2.c
parent646221d67de0d8ddfe9b35570c8e52a544e20194 (diff)
downloadgcc-3e3935a94ce8702a788cd3e76eab584ed09277e8.zip
gcc-3e3935a94ce8702a788cd3e76eab584ed09277e8.tar.gz
gcc-3e3935a94ce8702a788cd3e76eab584ed09277e8.tar.bz2
re PR c++/21280 (#pragma interface, templates, and "inline function used but never defined")
cp: PR c++/21280 * Make-lang.in (method.o): Add diagnostic.h * decl.c (start_preparsed_function): Use decl's location for file info. * decl2.c (cp_finish_file): Set input_location before synthesizing a function. (mark_used): When deferring a synthesized function, save current location. Do not set function's location when actually synthesizing it. * method.c: #include diagnostic.h. (synthesize_method): Set the functions source location. Show needed location if errors are emitted. testsuite: PR c++/21280 * g++.dg/opt/interface2.h: New. * g++.dg/opt/interface2.C: New. * g++.dg/init/ctor4.C: Adjust error lines. * g++.old-deja/g++.bob/inherit2.C: Likewise. * g++.old-deja/g++.bugs/900205_04.C: Likewise. * g++.old-deja/g++.jason/opeq3.C: Likewise. * g++.old-deja/g++.pt/assign1.C: Likewise. * g++.old-deja/g++.pt/crash20.C: Likewise. From-SVN: r100500
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r--gcc/cp/decl2.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 732e429..48febf7 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2966,6 +2966,10 @@ cp_finish_file (void)
finish_function doesn't clean things up, and we end
up with CURRENT_FUNCTION_DECL set. */
push_to_top_level ();
+ /* The decl's location will mark where it was first
+ needed. Save that so synthesize method can indicate
+ where it was needed from, in case of error */
+ input_location = DECL_SOURCE_LOCATION (decl);
synthesize_method (decl);
pop_from_top_level ();
reconsider = true;
@@ -3228,6 +3232,14 @@ mark_used (tree decl)
{
if (DECL_DEFERRED_FN (decl))
return;
+
+ /* Remember the current location for a function we will end up
+ synthesizing. Then we can inform the user where it was
+ required in the case of error. */
+ if (DECL_ARTIFICIAL (decl) && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl)
+ && !DECL_THUNK_P (decl))
+ DECL_SOURCE_LOCATION (decl) = input_location;
+
note_vague_linkage_fn (decl);
}
@@ -3245,14 +3257,6 @@ mark_used (tree decl)
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. */