[PATCH] D38342: [C++] Parse (sub) postfix expression after boolean literal

Nicolas Lesser via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 27 20:02:09 PDT 2017


Rakete1111 created this revision.
Rakete1111 added a project: clang.

Parsers a postfix expression after a boolean literal:

This fixes PR34273 <https://bugs.llvm.org/show_bug.cgi?id=34273>.


https://reviews.llvm.org/D38342

Files:
  lib/Parse/ParseExpr.cpp
  test/CXX/expr/expr.post/expr.sub/p1.cpp


Index: test/CXX/expr/expr.post/expr.sub/p1.cpp
===================================================================
--- test/CXX/expr/expr.post/expr.sub/p1.cpp
+++ test/CXX/expr/expr.post/expr.sub/p1.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void pr34273() {
+  char Normal = "clang"[true]; // expected-no-diagnostics
+  char Special = true["clang"]; // expected-no-diagnostics
+}
+
Index: lib/Parse/ParseExpr.cpp
===================================================================
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -798,7 +798,8 @@
 
   case tok::kw_true:
   case tok::kw_false:
-    return ParseCXXBoolLiteral();
+    Res = ParseCXXBoolLiteral();
+    break;
   
   case tok::kw___objc_yes:
   case tok::kw___objc_no:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38342.116917.patch
Type: text/x-patch
Size: 770 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170928/c3dd9359/attachment.bin>


More information about the cfe-commits mailing list