]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/20172 (Invalid non-type template parameters not diagnosed)
authorVolker Reichelt <reichelt@igpm.rwth-aachen.de>
Tue, 12 Jul 2005 16:07:38 +0000 (16:07 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 12 Jul 2005 16:07:38 +0000 (16:07 +0000)
cp:
PR c++/20172
* pt.c (tsubst_template_parms): Check for invalid non-type
parameters.
testsuite:
PR c++/20172
* g++.dg/template/nontype12.C : New test.

Co-Authored-By: Nathan Sidwell <nathan@codesourcery.com>
From-SVN: r101928

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/nontype12.C [new file with mode: 0644]

index 75da1b34e5c0a90ffe4d08587bd9583c337c078c..80a28022417d62f2c0c593671f7f02a1aef655fa 100644 (file)
@@ -1,3 +1,10 @@
+2005-07-12  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+           Nathan Sidwell  <nathan@codesourcery.com>
+
+       PR c++/20172
+       * pt.c (tsubst_template_parms): Check for invalid non-type
+       parameters.
+
 2005-07-09  Andrew Pinski  <pinskia@physics.uc.edu>
 
        * cp-lang.c (shadowed_var_for_decl, decl_shadowed_for_var_lookup,
index 0fcb5e85a54f65fe449ee24ae132056a5383a4ee..bbf3bf9bb34eefd9d52136b01cb953d5c20ef0ec 100644 (file)
@@ -5987,6 +5987,9 @@ tsubst_template_parms (tree parms, tree args, tsubst_flags_t complain)
          tree parm_decl = TREE_VALUE (tuple);
 
          parm_decl = tsubst (parm_decl, args, complain, NULL_TREE);
+         if (TREE_CODE (parm_decl) == PARM_DECL
+             && invalid_nontype_parm_type_p (TREE_TYPE (parm_decl), complain))
+           parm_decl = error_mark_node;
          default_value = tsubst_template_arg (default_value, args,
                                               complain, NULL_TREE);
 
index 2a0a5f8eb0010f7bafeaf2e0f538505283734da8..6502977bb18b9a17e65f11851ad41917ac89ed30 100644 (file)
@@ -1,3 +1,8 @@
+2005-07-12  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/20172
+       * g++.dg/template/nontype12.C : New test.
+
 2005-07-12  Zdenek Dvorak  <dvorakz@suse.cz>
 
        * gcc.dg/tree-ssa/loop-10.c: New test.
diff --git a/gcc/testsuite/g++.dg/template/nontype12.C b/gcc/testsuite/g++.dg/template/nontype12.C
new file mode 100644 (file)
index 0000000..0200e87
--- /dev/null
@@ -0,0 +1,35 @@
+// PR c++/20172
+// Origin: Volker Reichelt <reichelt@igpm.rwth-aachen.de>
+
+template<typename T> struct A
+{
+  template<T> int foo();                        // { dg-error "double" }
+  template<template<T> class> int bar();        // { dg-error "double" }
+  template<T> struct X;                         // { dg-error "double" }
+};
+
+A<char>   a1;
+A<double> a2;                                   // { dg-error "instantiated" }
+
+template<typename T> struct B
+{
+  template<double> int foo();                   // { dg-error "double" }
+  template<template<double> class> int bar();   // { dg-error "double" }
+  template<double> struct X;                    // { dg-error "double" }
+};
+
+template<void> int foo();                       // { dg-error "void" }
+template<template<void> class> int bar();       // { dg-error "void" }
+template<void> struct X;                        // { dg-error "void" }
+
+template<typename T> struct C
+{
+  template<T> int foo();                        // { dg-error "double" }
+};
+
+template<typename T> int baz(T) { C<T> c; }     // { dg-error "instantiated" }
+
+void foobar()
+{
+  baz(1.2);                                     // { dg-error "instantiated" }
+}
This page took 0.126 seconds and 5 git commands to generate.