aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/typeck.c20
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C15
-rw-r--r--gcc/testsuite/g++.dg/init/array21.C2
3 files changed, 29 insertions, 8 deletions
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index ef76dcd..66fb33a 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1880,19 +1880,25 @@ decay_conversion (tree exp, tsubst_flags_t complain)
return error_mark_node;
}
- /* FIXME remove? at least need to remember that this isn't really a
- constant expression if EXP isn't decl_constant_var_p, like with
- C_MAYBE_CONST_EXPR. */
- exp = decl_constant_value_safe (exp);
- if (error_operand_p (exp))
- return error_mark_node;
+ code = TREE_CODE (type);
+
+ /* For an array decl decay_conversion should not try to return its
+ initializer. */
+ if (code != ARRAY_TYPE)
+ {
+ /* FIXME remove? at least need to remember that this isn't really a
+ constant expression if EXP isn't decl_constant_var_p, like with
+ C_MAYBE_CONST_EXPR. */
+ exp = decl_constant_value_safe (exp);
+ if (error_operand_p (exp))
+ return error_mark_node;
+ }
if (NULLPTR_TYPE_P (type) && !TREE_SIDE_EFFECTS (exp))
return nullptr_node;
/* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
Leave such NOP_EXPRs, since RHS is being used in non-lvalue context. */
- code = TREE_CODE (type);
if (code == VOID_TYPE)
{
if (complain & tf_error)
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C
new file mode 100644
index 0000000..7ad5e6d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-30.C
@@ -0,0 +1,15 @@
+// Origin PR c++/55311
+// { dg-do compile { target c++11 } }
+
+template <const char *const C, typename T>
+struct A
+{};
+
+struct B {};
+
+extern constexpr char HELLO_WORLD[] = "hello world";
+
+A<HELLO_WORLD, B> g; // <-- This works fine
+
+template <typename T>
+using PartiallySpecialized = A<HELLO_WORLD, T>; // <-- This fails
diff --git a/gcc/testsuite/g++.dg/init/array21.C b/gcc/testsuite/g++.dg/init/array21.C
index 5438af1..fc6abab 100644
--- a/gcc/testsuite/g++.dg/init/array21.C
+++ b/gcc/testsuite/g++.dg/init/array21.C
@@ -3,5 +3,5 @@
void foo()
{
const int x[] = 0; // { dg-error "initializer" }
- ++x;
+ ++x; // { dg-error "read-only|operand" }
}