r314463 - Properly parse a postfix expression following a Boolean literal. Fixes PR34273.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 28 14:29:18 PDT 2017


Author: aaronballman
Date: Thu Sep 28 14:29:18 2017
New Revision: 314463

URL: http://llvm.org/viewvc/llvm-project?rev=314463&view=rev
Log:
Properly parse a postfix expression following a Boolean literal. Fixes PR34273.

Patch by Nicolas Lesser.

Modified:
    cfe/trunk/lib/Parse/ParseExpr.cpp
    cfe/trunk/test/Parser/cxx-bool.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=314463&r1=314462&r2=314463&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Thu Sep 28 14:29:18 2017
@@ -798,7 +798,8 @@ ExprResult Parser::ParseCastExpression(b
 
   case tok::kw_true:
   case tok::kw_false:
-    return ParseCXXBoolLiteral();
+    Res = ParseCXXBoolLiteral();
+    break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:

Modified: cfe/trunk/test/Parser/cxx-bool.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/cxx-bool.cpp?rev=314463&r1=314462&r2=314463&view=diff
==============================================================================
--- cfe/trunk/test/Parser/cxx-bool.cpp (original)
+++ cfe/trunk/test/Parser/cxx-bool.cpp Thu Sep 28 14:29:18 2017
@@ -1,4 +1,11 @@
-// RUN: %clang_cc1 -fsyntax-only %s
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
 
 bool a = true;
 bool b = false;
+
+namespace pr34273 {
+  char c = "clang"[true];
+  char d = true["clang"];
+}
+




More information about the cfe-commits mailing list