From: Gabriel Dos Reis Date: Wed, 16 Jul 2003 01:43:26 +0000 (+0000) Subject: re PR c++/10903 ([3.3 only] g++ says: "error: object ``type_decl' not supported by... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c61dce3a814a535c2d8c0ce1b8d7dd7e476116f8;p=gcc.git re PR c++/10903 ([3.3 only] g++ says: "error: object ``type_decl' not supported by dump_expr") PR c++/10903 * pt.c (convert_nontype_argument): Fix thinko in diagnostic. Improve. From-SVN: r69435 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b491c2b720b..4c750887af2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2003-07-16 Gabriel Dos Reis + + PR c++/10903 + * pt.c (convert_nontype_argument): Fix thinko in diagnostic. + Improve. + 2003-07-15 Mark Mitchell * cp-tree.def (LOOKUP_EXPR): Remove. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8712ce6efb7..1a8ea15c040 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3085,7 +3085,14 @@ convert_nontype_argument (tree type, tree expr) } else { - error ("object `%E' cannot be used as template argument", expr); + if (TYPE_P (expr)) + error ("type '%T' cannot be used as a value for a non-type " + "template-parameter", expr); + else if (DECL_P (expr)) + error ("invalid use of '%D' as a non-type template-argument", expr); + else + error ("invalid use of '%E' as a non-type template-argument", expr); + return NULL_TREE; } diff --git a/gcc/testsuite/g++.dg/template/non-type-template-argument-1.C b/gcc/testsuite/g++.dg/template/non-type-template-argument-1.C new file mode 100644 index 00000000000..fbe5f3f456b --- /dev/null +++ b/gcc/testsuite/g++.dg/template/non-type-template-argument-1.C @@ -0,0 +1,12 @@ +struct A { static const bool b=false; }; + +struct B { typedef A X; }; + +template struct C {}; + +template struct D +{ + C c; // { dg-error "invalid use" } +}; + +D d; // { dg-error "" }