summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2014-06-24 23:14:24 +0000
committerRichard Trieu <rtrieu@google.com>2014-06-24 23:14:24 +0000
commit3e11835412bb95edf3526dc16082ff61586100a5 (patch)
tree7a00fa5091c31442407561c18a65ebb5b9ea78aa /include
parent93d4222c228925c5c97d0e0190d7e614db1778f3 (diff)
downloadclang-3e11835412bb95edf3526dc16082ff61586100a5.tar.gz
clang-3e11835412bb95edf3526dc16082ff61586100a5.tar.bz2
clang-3e11835412bb95edf3526dc16082ff61586100a5.tar.xz
Provide a better diagnostic when braces are put before the identifier.
When a user types: int [4] foo; assume that the user means: int foo[4]; Update the information for 'foo' to prevent additional errors, and provide a fix-it hint to move the brackets to the correct location. Additionally, suggest parens for types that require it, such as: int [4] *foo; to: int (*foo)[4]; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211641 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/clang/Basic/DiagnosticParseKinds.td2
-rw-r--r--include/clang/Parse/Parser.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/include/clang/Basic/DiagnosticParseKinds.td b/include/clang/Basic/DiagnosticParseKinds.td
index bc097e0bf3..69e2fb3110 100644
--- a/include/clang/Basic/DiagnosticParseKinds.td
+++ b/include/clang/Basic/DiagnosticParseKinds.td
@@ -448,6 +448,8 @@ def err_invalid_operator_on_type : Error<
"cannot use %select{dot|arrow}0 operator on a type">;
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">;
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">;
diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h
index 586545eab8..104d4b6712 100644
--- a/include/clang/Parse/Parser.h
+++ b/include/clang/Parse/Parser.h
@@ -2214,6 +2214,7 @@ private:
SmallVectorImpl<DeclaratorChunk::ParamInfo> &ParamInfo,
SourceLocation &EllipsisLoc);
void ParseBracketDeclarator(Declarator &D);
+ void ParseMisplacedBracketDeclarator(Declarator &D);
//===--------------------------------------------------------------------===//
// C++ 7: Declarations [dcl.dcl]