]> granicus.if.org Git - clang/commitdiff
Improve recovery when we fail to parse the operand of a C++ named cast. Fixes PR5210
authorDouglas Gregor <dgregor@apple.com>
Fri, 6 Nov 2009 05:48:00 +0000 (05:48 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 6 Nov 2009 05:48:00 +0000 (05:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86234 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExprCXX.cpp
test/SemaCXX/cast-conversion.cpp

index a00dfb0b4c36bad7675a9600b3978a22c660ffa1..fa8e64dc125bb801e66da605199e33e907c3ca0a 100644 (file)
@@ -381,13 +381,7 @@ Parser::OwningExprResult Parser::ParseCXXCasts() {
   OwningExprResult Result = ParseExpression();
 
   // Match the ')'.
-  if (Result.isInvalid())
-    SkipUntil(tok::r_paren);
-
-  if (Tok.is(tok::r_paren))
-    RParenLoc = ConsumeParen();
-  else
-    MatchRHSPunctuation(tok::r_paren, LParenLoc);
+  RParenLoc = MatchRHSPunctuation(tok::r_paren, LParenLoc);
 
   if (!Result.isInvalid() && !CastTy.isInvalid())
     Result = Actions.ActOnCXXNamedCast(OpLoc, Kind,
index 936933d95d1fb0eed11e711b94b4c7ca153d00aa..3b6a9d6f8c492125e55700a8d8875381dcf1c569 100644 (file)
@@ -33,3 +33,14 @@ void test_X0() {
   const char array[2];
   make_X0(array);
 }
+
+// PR5210 recovery
+class C {
+protected:
+  template <int> float* &f0(); // expected-note{{candidate}}
+  template <unsigned> float* &f0(); // expected-note{{candidate}}
+
+  void f1() {
+    static_cast<float*>(f0<0>()); // expected-error{{ambiguous}}
+  }
+};