diff options
author | Chris Lattner <sabre@nondot.org> | 2008-10-26 23:22:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-10-26 23:22:23 +0000 |
commit | 79ed6b5902ed92175b70ed3c4d7b3f239af847ce (patch) | |
tree | 4adb53cb34d82e1410fb0a1f1404be79124f0f49 /lib/Parse/ParseInit.cpp | |
parent | e232942571a80549514791bbdbbd0bb44fab6b56 (diff) |
add some simple designator testcases. Reject things like this:
struct foo Y[10] = {
[4] .arr [2] 4 // expected-error {{expected '=' or another designator}}
};
because the "missing equals" extension only is valid if there
is exactly one array designator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58215 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseInit.cpp')
-rw-r--r-- | lib/Parse/ParseInit.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/Parse/ParseInit.cpp b/lib/Parse/ParseInit.cpp index ed30f64d93..f4d18fbb4c 100644 --- a/lib/Parse/ParseInit.cpp +++ b/lib/Parse/ParseInit.cpp @@ -176,6 +176,7 @@ ParseInitializerWithPotentialDesignator(InitListDesignations &Designations, // at least one designator, because the only case we can get into this method // without a designator is when we have an objc message send. That case is // handled and returned from above. + assert(Desig && "Designator didn't get created?"); // Handle a normal designator sequence end, which is an equal. if (Tok.is(tok::equal)) { @@ -184,15 +185,18 @@ ParseInitializerWithPotentialDesignator(InitListDesignations &Designations, } // We read some number of designators and found something that isn't an = or - // an initializer. If we have exactly one array designator [TODO CHECK], this + // an initializer. If we have exactly one array designator, this // is the GNU 'designation: array-designator' extension. Otherwise, it is a // parse error. - SourceLocation Loc = Tok.getLocation(); - ExprResult Init = ParseInitializer(); - if (Init.isInvalid) return Init; + if (Desig->getNumDesignators() == 1 && + (Desig->getDesignator(0).isArrayDesignator() || + Desig->getDesignator(0).isArrayRangeDesignator())) { + Diag(Tok, diag::ext_gnu_missing_equal_designator); + return ParseInitializer(); + } - Diag(Tok, diag::ext_gnu_missing_equal_designator); - return Init; + Diag(Tok, diag::err_expected_equal_designator); + return true; } |