This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH to add -fno-pretty-templates


A follow-on patch to always chase template typedefs with -fno-pretty-templates.

Tested x86_64-pc-linux-gnu, applied to trunk.
2009-04-08  Jason Merrill  <jason@redhat.com>

	PR c++/25185
	* error.c (dump_aggr_type): Chase template typedefs if
	-fno-pretty-templates.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index fc32d99..9c2e7e5 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -537,14 +537,22 @@ dump_aggr_type (tree t, int flags)
   if (flags & TFF_CLASS_KEY_OR_ENUM)
     pp_cxx_identifier (cxx_pp, variety);
 
-  if (flags & TFF_CHASE_TYPEDEF)
-    t = TYPE_MAIN_VARIANT (t);
-
   name = TYPE_NAME (t);
 
   if (name)
     {
       typdef = !DECL_ARTIFICIAL (name);
+
+      if (typdef
+	  && ((flags & TFF_CHASE_TYPEDEF)
+	      || (!flag_pretty_templates && DECL_LANG_SPECIFIC (name)
+		  && DECL_TEMPLATE_INFO (name))))
+	{
+	  t = TYPE_MAIN_VARIANT (t);
+	  name = TYPE_NAME (t);
+	  typdef = 0;
+	}
+
       tmplate = !typdef && TREE_CODE (t) != ENUMERAL_TYPE
 		&& TYPE_LANG_SPECIFIC (t) && CLASSTYPE_TEMPLATE_INFO (t)
 		&& (TREE_CODE (CLASSTYPE_TI_TEMPLATE (t)) != TEMPLATE_DECL
diff --git a/gcc/testsuite/g++.dg/template/error40.C b/gcc/testsuite/g++.dg/template/error40.C
index f449832..c5df56f 100644
--- a/gcc/testsuite/g++.dg/template/error40.C
+++ b/gcc/testsuite/g++.dg/template/error40.C
@@ -3,6 +3,7 @@
 template <class T, int N=0, int X=1>
 struct A
 {
+  struct AN;
 };
 
 void foo(void)
@@ -13,7 +14,17 @@ void foo(void)
 template <class T> T f(T);	    // { dg-message "int f<int>.int." }
 template <class T> T f(T, int = 0); // { dg-message "" }
 
+template <class T>
+struct B
+{
+  typedef typename T::AN BN;
+
+  BN f();			// { dg-message "AN" }
+  BN f(int = 0);		// { dg-message "" }
+};
+
 int main()
 {
   f(1);				// { dg-error "" }
+  B<A<int> >().f();		// { dg-error "" }
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]