aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-04-07 13:48:52 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-04-07 13:48:52 -0400
commit6ea2bd47dd50fdf50e5b71e7349dae094f2920fe (patch)
treeaaa87a15f5942f4f114e17e7f79c23571f506e9b /gcc
parenta2dc5812ff7b8d195399c4f9513dcf0376eba4d5 (diff)
downloadgcc-6ea2bd47dd50fdf50e5b71e7349dae094f2920fe.zip
gcc-6ea2bd47dd50fdf50e5b71e7349dae094f2920fe.tar.gz
gcc-6ea2bd47dd50fdf50e5b71e7349dae094f2920fe.tar.bz2
re PR c++/25185 (deep typedef substitution in error message)
PR c++/25185 * c-common.h, c-common.c: Add flag_pretty_templates. * c-opts.c (c_common_handle_option): Set it. * c.opt: Add -fno-pretty-templates. * doc/invoke.texi (C++ Dialect Options): Likewise. * error.c (dump_function_decl): Don't pretty-print templates if -fno-pretty-templates. (count_non_default_template_args): Print all args if -fno-pretty-templates. From-SVN: r145697
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/c-common.c5
-rw-r--r--gcc/c-common.h5
-rw-r--r--gcc/c-opts.c4
-rw-r--r--gcc/c.opt4
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/error.c5
-rw-r--r--gcc/doc/invoke.texi14
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/template/error40.C19
10 files changed, 75 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e52e732..6f44891 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2009-04-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/25185
+ * c-common.h, c-common.c: Add flag_pretty_templates.
+ * c-opts.c (c_common_handle_option): Set it.
+ * c.opt: Add -fno-pretty-templates.
+ * doc/invoke.texi (C++ Dialect Options): Likewise.
+
2009-04-07 Uros Bizjak <ubizjak@gmail.com>
* config/ia64/ia64.c (ia64_builtins): Add IA64_BUILTIN_HUGE_VALQ.
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 9886cdf..3d11455 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -593,6 +593,11 @@ int flag_enforce_eh_specs = 1;
int flag_threadsafe_statics = 1;
+/* Nonzero if we want to pretty-print template specializations as the
+ template signature followed by the arguments. */
+
+int flag_pretty_templates = 1;
+
/* Nonzero means warn about implicit declarations. */
int warn_implicit = 1;
diff --git a/gcc/c-common.h b/gcc/c-common.h
index f5c755b..0d85a93 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -695,6 +695,11 @@ extern int flag_enforce_eh_specs;
extern int flag_threadsafe_statics;
+/* Nonzero if we want to pretty-print template specializations as the
+ template signature followed by the arguments. */
+
+extern int flag_pretty_templates;
+
/* Nonzero means warn about implicit declarations. */
extern int warn_implicit;
diff --git a/gcc/c-opts.c b/gcc/c-opts.c
index 3953991..54edf30 100644
--- a/gcc/c-opts.c
+++ b/gcc/c-opts.c
@@ -808,6 +808,10 @@ c_common_handle_option (size_t scode, const char *arg, int value)
flag_threadsafe_statics = value;
break;
+ case OPT_fpretty_templates:
+ flag_pretty_templates = value;
+ break;
+
case OPT_fzero_link:
flag_zero_link = value;
break;
diff --git a/gcc/c.opt b/gcc/c.opt
index 40681bd..3f1cd13 100644
--- a/gcc/c.opt
+++ b/gcc/c.opt
@@ -716,6 +716,10 @@ fpreprocessed
C ObjC C++ ObjC++
Treat the input file as already preprocessed
+fpretty-templates
+C++ ObjC++
+-fno-pretty-templates Do not pretty-print template specializations as the template signature followed by the arguments
+
freplace-objc-classes
ObjC ObjC++
Used in Fix-and-Continue mode to indicate that object files may be swapped in at runtime
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 02440e5..08daf46 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+2009-04-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/25185
+ * error.c (dump_function_decl): Don't pretty-print templates
+ if -fno-pretty-templates.
+ (count_non_default_template_args): Print all args if
+ -fno-pretty-templates.
+
2009-04-06 Jason Merrill <jason@redhat.com>
PR c++/35146
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index a97017a..fc32d99 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -163,7 +163,7 @@ count_non_default_template_args (tree args, tree params)
int n = TREE_VEC_LENGTH (args);
int last;
- if (params == NULL_TREE)
+ if (params == NULL_TREE || !flag_pretty_templates)
return n;
for (last = n - 1; last >= 0; --last)
@@ -1206,7 +1206,8 @@ dump_function_decl (tree t, int flags)
exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (t));
/* Pretty print template instantiations only. */
- if (DECL_USE_TEMPLATE (t) && DECL_TEMPLATE_INFO (t))
+ if (DECL_USE_TEMPLATE (t) && DECL_TEMPLATE_INFO (t)
+ && flag_pretty_templates)
{
tree tmpl;
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 5eb9776..b5d795a 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -188,6 +188,7 @@ in the following sections.
-fno-implement-inlines -fms-extensions @gol
-fno-nonansi-builtins -fno-operator-names @gol
-fno-optional-diags -fpermissive @gol
+-fno-pretty-templates @gol
-frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol
-fno-threadsafe-statics -fuse-cxa-atexit -fno-weak -nostdinc++ @gol
-fno-default-inline -fvisibility-inlines-hidden @gol
@@ -1834,6 +1835,19 @@ Downgrade some diagnostics about nonconformant code from errors to
warnings. Thus, using @option{-fpermissive} will allow some
nonconforming code to compile.
+@item -fno-pretty-templates
+@opindex fno-pretty-templates
+When an error message refers to a specialization of a function
+template, the compiler will normally print the signature of the
+template followed by the template arguments and any typedefs or
+typenames in the signature (e.g. @code{void f(T) [with T = int]}
+rather than @code{void f(int)}) so that it's clear which template is
+involved. When an error message refers to a specialization of a class
+template, the compiler will omit any template arguments which match
+the default template arguments for that template. If either of these
+behaviors make it harder to understand the error message rather than
+easier, using @option{-fno-pretty-templates} will disable them.
+
@item -frepo
@opindex frepo
Enable automatic template instantiation at link time. This option also
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 688d1b5..a48515a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-07 Jason Merrill <jason@redhat.com>
+
+ PR c++/25185
+ * g++.dg/template/error40.C: New.
+
2009-04-07 Janus Weil <janus@gcc.gnu.org>
PR fortran/38152
diff --git a/gcc/testsuite/g++.dg/template/error40.C b/gcc/testsuite/g++.dg/template/error40.C
new file mode 100644
index 0000000..f449832
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/error40.C
@@ -0,0 +1,19 @@
+// { dg-options "-fno-pretty-templates" }
+
+template <class T, int N=0, int X=1>
+struct A
+{
+};
+
+void foo(void)
+{
+ A<void> a = 0; // { dg-error "A<void, 0, 1>" }
+}
+
+template <class T> T f(T); // { dg-message "int f<int>.int." }
+template <class T> T f(T, int = 0); // { dg-message "" }
+
+int main()
+{
+ f(1); // { dg-error "" }
+}