r236344 - Adjust the wording of the "brackets go after the unqualified-id" error message. It applies in cases that aren't unqualified-ids.

Nick Lewycky nicholas at mxc.ca
Fri May 1 13:47:19 PDT 2015


Author: nicholas
Date: Fri May  1 15:47:19 2015
New Revision: 236344

URL: http://llvm.org/viewvc/llvm-project?rev=236344&view=rev
Log:
Adjust the wording of the "brackets go after the unqualified-id" error message. It applies in cases that aren't unqualified-ids.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
    cfe/trunk/test/Parser/brackets.c
    cfe/trunk/test/Parser/brackets.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td?rev=236344&r1=236343&r2=236344&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticParseKinds.td Fri May  1 15:47:19 2015
@@ -477,7 +477,8 @@ def err_invalid_operator_on_type : Error
 def err_expected_unqualified_id : Error<
   "expected %select{identifier|unqualified-id}0">;
 def err_brackets_go_after_unqualified_id : Error<
-  "brackets go after the %select{identifier|unqualified-id}0">;
+  "brackets are not allowed here; to declare an array, "
+  "place the brackets after the %select{identifier|name}0">;
 def err_unexpected_unqualified_id : Error<"type-id cannot have a name">;
 def err_func_def_no_params : Error<
   "function definition does not declare parameters">;

Modified: cfe/trunk/test/Parser/brackets.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/brackets.c?rev=236344&r1=236343&r2=236344&view=diff
==============================================================================
--- cfe/trunk/test/Parser/brackets.c (original)
+++ cfe/trunk/test/Parser/brackets.c Fri May  1 15:47:19 2015
@@ -7,7 +7,7 @@
 void test1() {
   int a[] = {0,1,1,2,3};
   int []b = {0,1,4,9,16};
-  // expected-error at -1{{brackets go after the identifier}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
   // CHECK: {{^}}  int []b = {0,1,4,9,16};
   // CHECK: {{^}}      ~~ ^
   // CHECK: {{^}}         []
@@ -23,7 +23,7 @@ void test1() {
 
 struct S {
   int [1][1]x;
-  // expected-error at -1{{brackets go after the identifier}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
   // CHECK: {{^}}  int [1][1]x;
   // CHECK: {{^}}      ~~~~~~ ^
   // CHECK: {{^}}             [1][1]
@@ -53,7 +53,7 @@ void test3() {
   // CHECK: {{^}}  int [5] *;
   // CHECK: {{^}}           ^
   // CHECK-NOT: fix-it
-  // expected-error at -5{{brackets go after the identifier}}
+  // expected-error at -5{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
   // CHECK: {{^}}  int [5] *;
   // CHECK: {{^}}      ~~~~ ^
   // CHECK: {{^}}          ()[5]
@@ -62,7 +62,7 @@ void test3() {
   // CHECK: fix-it:{{.*}}:{[[@LINE-11]]:12-[[@LINE-11]]:12}:")[5]"
 
   int [5] * a;
-  // expected-error at -1{{brackets go after the identifier}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the identifier}}
   // CHECK: {{^}}  int [5] * a;
   // CHECK: {{^}}      ~~~~   ^
   // CHECK: {{^}}          (  )[5]

Modified: cfe/trunk/test/Parser/brackets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/brackets.cpp?rev=236344&r1=236343&r2=236344&view=diff
==============================================================================
--- cfe/trunk/test/Parser/brackets.cpp (original)
+++ cfe/trunk/test/Parser/brackets.cpp Fri May  1 15:47:19 2015
@@ -7,7 +7,7 @@
 void test1() {
   int a[] = {0,1,1,2,3};
   int []b = {0,1,4,9,16};
-  // expected-error at -1{{brackets go after the unqualified-id}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
   // CHECK: {{^}}  int []b = {0,1,4,9,16};
   // CHECK: {{^}}      ~~ ^
   // CHECK: {{^}}         []
@@ -21,7 +21,7 @@ void test1() {
   int *f = b;  // No undeclared identifer error here.
 
   int[1] g[2];
-  // expected-error at -1{{brackets go after the unqualified-id}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
   // CHECK: {{^}}  int[1] g[2];
   // CHECK: {{^}}     ~~~     ^
   // CHECK: {{^}}             [1]
@@ -31,7 +31,7 @@ void test1() {
 
 void test2() {
   int [3] (*a) = 0;
-  // expected-error at -1{{brackets go after the unqualified-id}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
   // CHECK: {{^}}  int [3] (*a) = 0;
   // CHECK: {{^}}      ~~~~    ^
   // CHECK: {{^}}              [3]
@@ -47,7 +47,7 @@ void test2() {
 
 struct A {
   static int [1][1]x;
-  // expected-error at -1{{brackets go after the unqualified-id}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
   // CHECK: {{^}}  static int [1][1]x;
   // CHECK: {{^}}             ~~~~~~ ^
   // CHECK: {{^}}                    [1][1]
@@ -56,7 +56,7 @@ struct A {
 };
 
 int [1][1]A::x = { {42} };
-// expected-error at -1{{brackets go after the unqualified-id}}
+// expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
 // CHECK: {{^}}int [1][1]A::x = { {42} };
 // CHECK: {{^}}    ~~~~~~    ^
 // CHECK: {{^}}              [1][1]
@@ -65,7 +65,7 @@ int [1][1]A::x = { {42} };
 
 struct B { static int (*x)[5]; };
 int [5] *B::x = 0;
-// expected-error at -1{{brackets go after the unqualified-id}}
+// expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
 // CHECK: {{^}}int [5] *B::x = 0;
 // CHECK: {{^}}    ~~~~     ^
 // CHECK: {{^}}        (    )[5]
@@ -75,7 +75,7 @@ int [5] *B::x = 0;
 
 void test3() {
   int [3] *a;
-  // expected-error at -1{{brackets go after the unqualified-id}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
   // CHECK: {{^}}  int [3] *a;
   // CHECK: {{^}}      ~~~~  ^
   // CHECK: {{^}}          ( )[3]
@@ -88,7 +88,7 @@ void test3() {
 
 void test4() {
   int [2] a;
-  // expected-error at -1{{brackets go after the unqualified-id}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
   // CHECK: {{^}}  int [2] a;
   // CHECK: {{^}}      ~~~~ ^
   // CHECK: {{^}}           [2]
@@ -96,7 +96,7 @@ void test4() {
   // CHECK: fix-it:{{.*}}:{[[@LINE-6]]:12-[[@LINE-6]]:12}:"[2]"
 
   int [2] &b = a;
-  // expected-error at -1{{brackets go after the unqualified-id}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
   // CHECK: {{^}}  int [2] &b = a;
   // CHECK: {{^}}      ~~~~  ^
   // CHECK: {{^}}          ( )[2]
@@ -128,7 +128,7 @@ struct A {
   static int arr[3];
 };
 int [3] ::test6::A::arr = {1,2,3};
-// expected-error at -1{{brackets go after the unqualified-id}}
+// expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
 // CHECK: {{^}}int [3] ::test6::A::arr = {1,2,3};
 // CHECK: {{^}}    ~~~~               ^
 // CHECK: {{^}}                       [3]
@@ -141,7 +141,7 @@ namespace test7 {
 class A{};
 void test() {
   int [3] A::*a;
-  // expected-error at -1{{brackets go after the unqualified-id}}
+  // expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
   // CHECK: {{^}}  int [3] A::*a;
   // CHECK: {{^}}      ~~~~     ^
   // CHECK: {{^}}          (    )[3]
@@ -150,4 +150,12 @@ void test() {
   // CHECK: fix-it:{{.*}}:{[[@LINE-7]]:16-[[@LINE-7]]:16}:")[3]"
 }
 }
-// CHECK: 14 errors generated.
+
+namespace test8 {
+struct A {
+  static const char f[];
+};
+const char[] A::f = "f";
+// expected-error at -1{{brackets are not allowed here; to declare an array, place the brackets after the name}}
+}
+// CHECK: 15 errors generated.





More information about the cfe-commits mailing list