Index: c-typeck.c
===================================================================
--- c-typeck.c	(revision 186961)
+++ c-typeck.c	(working copy)
@@ -2338,30 +2338,11 @@ build_array_ref (location_t loc, tree ar
   /* Apply default promotions *after* noticing character types.  */
   index = default_conversion (index);
 
   gcc_assert (TREE_CODE (TREE_TYPE (index)) == INTEGER_TYPE);
 
-  /* For vector[index], convert the vector to a
-     pointer of the underlying type.  */
-  if (TREE_CODE (TREE_TYPE (array)) == VECTOR_TYPE)
-    {
-      tree type = TREE_TYPE (array);
-      tree type1;
-
-      if (TREE_CODE (index) == INTEGER_CST)
-        if (!host_integerp (index, 1)
-            || ((unsigned HOST_WIDE_INT) tree_low_cst (index, 1)
-               >= TYPE_VECTOR_SUBPARTS (TREE_TYPE (array))))
-          warning_at (loc, OPT_Warray_bounds, "index value is out of bound");
-
-      c_common_mark_addressable_vec (array);
-      type = build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type));
-      type = build_pointer_type (type);
-      type1 = build_pointer_type (TREE_TYPE (array));
-      array = build1 (ADDR_EXPR, type1, array);
-      array = convert (type, array);
-    }
+  convert_vector_to_pointer_for_subscript (loc, &array, index);
 
   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
     {
       tree rval, type;
 
Index: c-family/c-common.c
===================================================================
--- c-family/c-common.c	(revision 186961)
+++ c-family/c-common.c	(working copy)
@@ -10831,6 +10831,31 @@ build_userdef_literal (tree suffix_id, t
   USERDEF_LITERAL_VALUE (literal) = value;
   USERDEF_LITERAL_NUM_STRING (literal) = num_string;
   return literal;
 }
 
+/* For vector[index], convert the vector to a
+   pointer of the underlying type.  */
+void
+convert_vector_to_pointer_for_subscript (location_t loc, tree* vecp, tree index)
+{
+  if (TREE_CODE (TREE_TYPE (*vecp)) == VECTOR_TYPE)
+    {
+      tree type = TREE_TYPE (*vecp);
+      tree type1;
+
+      if (TREE_CODE (index) == INTEGER_CST)
+        if (!host_integerp (index, 1)
+            || ((unsigned HOST_WIDE_INT) tree_low_cst (index, 1)
+               >= TYPE_VECTOR_SUBPARTS (type)))
+          warning_at (loc, OPT_Warray_bounds, "index value is out of bound");
+
+      c_common_mark_addressable_vec (*vecp);
+      type = build_qualified_type (TREE_TYPE (type), TYPE_QUALS (type));
+      type = build_pointer_type (type);
+      type1 = build_pointer_type (TREE_TYPE (*vecp));
+      *vecp = build1 (ADDR_EXPR, type1, *vecp);
+      *vecp = convert (type, *vecp);
+    }
+}
+
 #include "gt-c-family-c-common.h"
Index: c-family/c-common.h
===================================================================
--- c-family/c-common.h	(revision 186961)
+++ c-family/c-common.h	(working copy)
@@ -1117,6 +1117,8 @@ struct GTY(()) tree_userdef_literal {
 #define USERDEF_LITERAL_TYPE(NODE) \
   (TREE_TYPE (USERDEF_LITERAL_VALUE (NODE)))
 
 extern tree build_userdef_literal (tree suffix_id, tree value, tree num_string);
 
+extern void convert_vector_to_pointer_for_subscript (location_t, tree*, tree);
+
 #endif /* ! GCC_C_COMMON_H */
Index: doc/extend.texi
===================================================================
--- doc/extend.texi	(revision 186961)
+++ doc/extend.texi	(working copy)
@@ -6821,11 +6821,11 @@ a = b + 1;    /* a = b + @{1,1,1,1@}; */
 a = 2 * b;    /* a = @{2,2,2,2@} * b; */
 
 a = l + a;    /* Error, cannot convert long to int. */
 @end smallexample
 
-In C vectors can be subscripted as if the vector were an array with
+Vectors can be subscripted as if the vector were an array with
 the same number of elements and base type.  Out of bound accesses
 invoke undefined behavior at runtime.  Warnings for out of bound
 accesses for vector subscription can be enabled with
 @option{-Warray-bounds}.
 
Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 186961)
+++ cp/decl2.c	(working copy)
@@ -371,11 +371,11 @@ grok_array_decl (tree array_expr, tree i
 
       /* Otherwise, create an ARRAY_REF for a pointer or array type.
 	 It is a little-known fact that, if `a' is an array and `i' is
 	 an int, you can write `i[a]', which means the same thing as
 	 `a[i]'.  */
-      if (TREE_CODE (type) == ARRAY_TYPE)
+      if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == VECTOR_TYPE)
 	p1 = array_expr;
       else
 	p1 = build_expr_type_conversion (WANT_POINTER, array_expr, false);
 
       if (TREE_CODE (TREE_TYPE (index_exp)) == ARRAY_TYPE)
Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 186961)
+++ cp/typeck.c	(working copy)
@@ -2913,10 +2913,12 @@ cp_build_array_ref (location_t loc, tree
 
     default:
       break;
     }
 
+  convert_vector_to_pointer_for_subscript (loc, &array, idx);
+
   if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
     {
       tree rval, type;
 
       warn_array_subscript_with_type_char (idx);
Index: testsuite/c-c++-common/vector-3.c
===================================================================
--- testsuite/c-c++-common/vector-3.c	(revision 186961)
+++ testsuite/c-c++-common/vector-3.c	(working copy)
@@ -1,5 +1,8 @@
 /* { dg-do compile } */
 
 /* Check that we error out when using vector_size on the bool type. */
 
+#ifdef __cplusplus
+#define _Bool bool
+#endif
 __attribute__((vector_size(16) )) _Bool a; /* { dg-error "" } */
Index: testsuite/c-c++-common/vector-subscript-1.c
===================================================================
--- testsuite/c-c++-common/vector-subscript-1.c	(revision 186961)
+++ testsuite/c-c++-common/vector-subscript-1.c	(working copy)
@@ -4,11 +4,11 @@
 #define vector __attribute__((vector_size(16) ))
 /* Check that vector[index] works and index[vector] is rejected.  */
 
 float vf(vector float a)
 {
-  return 0[a]; /* { dg-error "subscripted value is neither array nor pointer nor vector" } */
+  return 0[a]; /* { dg-error "subscripted value is neither array nor pointer nor vector|invalid types .* for array subscript" } */
 }
 
 
 float fv(vector float a)
 {
