]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/41972 (nondependent static member function as a reference template paramete...
authorJason Merrill <jason@redhat.com>
Mon, 9 Nov 2009 22:01:09 +0000 (17:01 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 9 Nov 2009 22:01:09 +0000 (17:01 -0500)
PR c++/41972
* parser.c (cp_parser_template_argument): Accept SCOPE_REF around
VAR_DECL.

From-SVN: r154053

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

index 7477e82161d027f6a9cf597b8dae3eac215e30b9..283b2399ad7939f9a78d8d94d7615fd818169641 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-09  Jason Merrill  <jason@redhat.com>
+
+       PR c++/41972
+       * parser.c (cp_parser_template_argument): Accept SCOPE_REF around
+       VAR_DECL.
+
 2009-11-04  Jason Merrill  <jason@redhat.com>
 
        PR c++/35067
index 4c4ba9c2d1de1243294d21b078bdedd5ce97988f..d13cf379a558220fb8e00b068439f788847103ce 100644 (file)
@@ -10296,18 +10296,26 @@ cp_parser_template_argument (cp_parser* parser)
        cp_parser_abort_tentative_parse (parser);
       else
        {
+         tree probe;
+
          if (TREE_CODE (argument) == INDIRECT_REF)
            {
              gcc_assert (REFERENCE_REF_P (argument));
              argument = TREE_OPERAND (argument, 0);
            }
 
-         if (TREE_CODE (argument) == VAR_DECL)
+         /* If we're in a template, we represent a qualified-id referring
+            to a static data member as a SCOPE_REF even if the scope isn't
+            dependent so that we can check access control later.  */
+         probe = argument;
+         if (TREE_CODE (probe) == SCOPE_REF)
+           probe = TREE_OPERAND (probe, 1);
+         if (TREE_CODE (probe) == VAR_DECL)
            {
              /* A variable without external linkage might still be a
                 valid constant-expression, so no error is issued here
                 if the external-linkage check fails.  */
-             if (!address_p && !DECL_EXTERNAL_LINKAGE_P (argument))
+             if (!address_p && !DECL_EXTERNAL_LINKAGE_P (probe))
                cp_parser_simulate_error (parser);
            }
          else if (is_overloaded_fn (argument))
index cd44c06eeaf8b44fc88577d511b60939e9b739b0..cf487e7f93f8d8686a740e59ac25ab22026a1f50 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-09  Jason Merrill  <jason@redhat.com>
+
+       PR c++/41972
+       * g++.dg/template/ref4.C: New.
+
 2009-11-04  Jason Merrill  <jason@redhat.com>
 
        PR c++/36912
diff --git a/gcc/testsuite/g++.dg/template/ref4.C b/gcc/testsuite/g++.dg/template/ref4.C
new file mode 100644 (file)
index 0000000..6d89fa8
--- /dev/null
@@ -0,0 +1,12 @@
+// PR c++/41972
+
+struct X {
+  static const double  x;
+};
+template <const double& _test_>
+  class Foo { };
+template <typename _ignore_>
+struct Y {
+  typedef Foo<X::x> type;
+};
+