* [patch] Fix for PR44641: wrong locations of generated functions
@ 2010-07-20 0:40 Jeffrey Yasskin
2010-07-20 3:42 ` Jason Merrill
0 siblings, 1 reply; 2+ messages in thread
From: Jeffrey Yasskin @ 2010-07-20 0:40 UTC (permalink / raw)
To: gcc-patches, jason
[-- Attachment #1: Type: text/plain, Size: 650 bytes --]
Here's a fix for PR44641. The tests are a superset of the patch at
http://gcc.gnu.org/ml/gcc-patches/2010-07/msg01533.html. I ran
check-g++ on Linux and the new tests on Darwin.
gcc/cp/ChangeLog:
2010-07-19 Jeffrey Yasskin <jyasskin@google.com>
* pt.c (instantiate_class_template): Propagate the template's
location to its instance.
gcc/testsuite/ChangeLog:
2010-07-19 Jeffrey Yasskin <jyasskin@google.com>
* lib/scanasm.exp (dg-function-on-line): Test that a function
is defined on the current line.
* g++.dg/debug/dwarf2/lineno-simple1.C: New. Line number sanity test.
* g++.dg/debug/dwarf2/pr44641.C: New.
[-- Attachment #2: pr44641.patch --]
[-- Type: application/octet-stream, Size: 4214 bytes --]
Index: gcc/testsuite/g++.dg/debug/dwarf2/pr44641.C
===================================================================
--- gcc/testsuite/g++.dg/debug/dwarf2/pr44641.C (revision 0)
+++ gcc/testsuite/g++.dg/debug/dwarf2/pr44641.C (revision 0)
@@ -0,0 +1,41 @@
+// Origin: PR 44641
+// { dg-do compile }
+// { dg-options "-g -O0 -dA" }
+
+template <class A> struct MisplacedDbg;
+template<class T> struct MisplacedDbg<T*>;
+struct Full;
+template<> struct MisplacedDbg<Full>;
+
+struct Arg;
+typedef MisplacedDbg<Arg> Typedef1;
+typedef MisplacedDbg<Arg*> Typedef2;
+typedef MisplacedDbg<Full> Typedef3;
+
+template<typename T> struct Base {
+ virtual ~Base() {
+ }
+};
+
+template <>
+struct MisplacedDbg<Full> // { dg-function-on-line {_ZN12MisplacedDbgI4FullEC[12]Ev} }
+ // { dg-function-on-line {_ZN12MisplacedDbgI4FullED0Ev} { target *-*-* } 21 }
+
+ : public Base<int> {
+};
+
+template <class T>
+struct MisplacedDbg<T*> // { dg-function-on-line {_ZN12MisplacedDbgIP3ArgEC[12]Ev} }
+ // { dg-function-on-line {_ZN12MisplacedDbgIP3ArgED0Ev} { target *-*-* } 28 }
+ : public Base<int> {
+};
+
+template <class A>
+struct MisplacedDbg // { dg-function-on-line {_ZN12MisplacedDbgI3ArgEC[12]Ev} }
+ // { dg-function-on-line {_ZN12MisplacedDbgI3ArgED0Ev} { target *-*-* } 34 }
+ : public Base<int> {
+};
+
+static MisplacedDbg<Arg> static_var1;
+static MisplacedDbg<Arg*> static_var2;
+static MisplacedDbg<Full> static_var3;
Index: gcc/testsuite/g++.dg/debug/dwarf2/lineno-simple1.C
===================================================================
--- gcc/testsuite/g++.dg/debug/dwarf2/lineno-simple1.C (revision 0)
+++ gcc/testsuite/g++.dg/debug/dwarf2/lineno-simple1.C (revision 0)
@@ -0,0 +1,13 @@
+// { dg-do compile }
+// { dg-options "-g -O0 -dA" }
+
+struct C { // { dg-function-on-line {_ZN1CC[12]Ev} }
+ virtual void
+ foo() {} // { dg-function-on-line _ZN1C3fooEv }
+};
+static C dummy;
+
+int
+main (void)
+{ // { dg-function-on-line main }
+}
Index: gcc/testsuite/lib/scanasm.exp
===================================================================
--- gcc/testsuite/lib/scanasm.exp (revision 162315)
+++ gcc/testsuite/lib/scanasm.exp (working copy)
@@ -291,3 +291,40 @@ proc scan-assembler-dem-not { args } {
fail "$testcase scan-assembler-dem-not $pp_pattern"
}
}
+
+# Utility for testing that a function is defined on the current line.
+# Call pass if so, otherwise fail. Invoked directly; the file must
+# have been compiled with -g -dA.
+#
+# Argument 0 is the current line, passed implicitly by dejagnu
+# Argument 1 is the function to check
+# Argument 2 handles expected failures and the like
+# Argument 3 is "." to match the current line, or an integer to match
+# an explicit line.
+proc dg-function-on-line { args } {
+ # Upvar from dg-final:
+ upvar dg-final-code final-code
+
+ set line [lindex $args 0]
+ set symbol [lindex $args 1]
+ set failures [lindex $args 2]
+
+ if { [llength $args] >= 4 } {
+ switch [lindex $args 3] {
+ "." { }
+ "default" { set line [lindex $args 3] }
+ }
+ }
+
+ set pattern [format {%s:[^\t]*(\t.file[^\t]*)?\t# \S*:%d\n} \
+ $symbol $line]
+
+ # The lack of spaces around $pattern is important, since they'd
+ # become part of the regex scan-assembler tries to match.
+ set cmd "scan-assembler {$pattern}"
+ if { [llength $args] >= 3 } {
+ set cmd "$cmd {$failures}"
+ }
+
+ append final-code "$cmd\n"
+}
Index: gcc/cp/pt.c
===================================================================
--- gcc/cp/pt.c (revision 162315)
+++ gcc/cp/pt.c (working copy)
@@ -7832,7 +7832,8 @@ instantiate_class_template (tree type)
/* Set the input location to the most specialized template definition.
This is needed if tsubsting causes an error. */
typedecl = TYPE_MAIN_DECL (pattern);
- input_location = DECL_SOURCE_LOCATION (typedecl);
+ input_location = DECL_SOURCE_LOCATION (TYPE_NAME (type)) =
+ DECL_SOURCE_LOCATION (typedecl);
TYPE_HAS_USER_CONSTRUCTOR (type) = TYPE_HAS_USER_CONSTRUCTOR (pattern);
TYPE_HAS_NEW_OPERATOR (type) = TYPE_HAS_NEW_OPERATOR (pattern);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] Fix for PR44641: wrong locations of generated functions
2010-07-20 0:40 [patch] Fix for PR44641: wrong locations of generated functions Jeffrey Yasskin
@ 2010-07-20 3:42 ` Jason Merrill
0 siblings, 0 replies; 2+ messages in thread
From: Jason Merrill @ 2010-07-20 3:42 UTC (permalink / raw)
To: Jeffrey Yasskin; +Cc: gcc-patches
OK.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-20 3:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-20 0:40 [patch] Fix for PR44641: wrong locations of generated functions Jeffrey Yasskin
2010-07-20 3:42 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).