Bump... another really small patch.

On Mon, Jan 9, 2012 at 11:17 PM, David Blaikie <[email protected]> wrote:
> 3rd time's the charm... sorry for the noise.
>
> On Mon, Jan 9, 2012 at 11:14 PM, David Blaikie <[email protected]> wrote:
>> Oops - updated test (removed some previously expected warnings that
>> don't fire any more since we've got some of the uniform initialization
>> stuff working now)
>>
>> On Mon, Jan 9, 2012 at 10:23 PM, David Blaikie <[email protected]> wrote:
>>> Bump (patch resync'd to recent revision)
>>>
>>> On Tue, Dec 13, 2011 at 4:12 PM, David Blaikie <[email protected]> wrote:
>>>> & of course I forgot to include the patch... here we go.
>>>>
>>>> On Tue, Dec 13, 2011 at 4:11 PM, David Blaikie <[email protected]> wrote:
>>>>> This patch adds support for decltype in simple-type-specifiers such as:
>>>>>
>>>>> struct foo { foo(int); };
>>>>> foo func() {
>>>>>  return decltype(foo())(3);
>>>>> }
>>>>>
>>>>> I'm not sure how much testing would be desired here - I could go
>>>>> through the spec & find all the uses of simple-type-specifier & add
>>>>> test cases that verify that decltype works in such contexts but for
>>>>> now I've done a smattering of those cases & things seem to be working
>>>>> fairly nicely.
>>>>>
>>>>> Let me know if this is suitable,
>>>>> - David
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index bdebb5e..606c108 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -914,6 +914,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
     }
     // Fall through
       
+  case tok::annot_decltype:
   case tok::kw_char:
   case tok::kw_wchar_t:
   case tok::kw_char16_t:
diff --git a/lib/Parse/ParseExprCXX.cpp b/lib/Parse/ParseExprCXX.cpp
index 8046f6b..37d9b5b 100644
--- a/lib/Parse/ParseExprCXX.cpp
+++ b/lib/Parse/ParseExprCXX.cpp
@@ -1418,8 +1418,11 @@ void Parser::ParseCXXSimpleTypeSpecifier(DeclSpec &DS) {
   case tok::kw_bool:
     DS.SetTypeSpecType(DeclSpec::TST_bool, Loc, PrevSpec, DiagID);
     break;
+  case tok::annot_decltype:
+  case tok::kw_decltype:
+    DS.SetRangeEnd(ParseDecltypeSpecifier(DS));
+    return DS.Finish(Diags, PP);
 
-    // FIXME: C++0x decltype support.
   // GNU typeof support.
   case tok::kw_typeof:
     ParseTypeofSpecifier(DS);
diff --git a/lib/Parse/ParseTentative.cpp b/lib/Parse/ParseTentative.cpp
index fe46456..4f80da2 100644
--- a/lib/Parse/ParseTentative.cpp
+++ b/lib/Parse/ParseTentative.cpp
@@ -1009,6 +1009,7 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
   case tok::kw_float:
   case tok::kw_double:
   case tok::kw_void:
+  case tok::annot_decltype:
     if (NextToken().is(tok::l_paren))
       return TPResult::Ambiguous();
 
@@ -1038,10 +1039,6 @@ Parser::TPResult Parser::isCXXDeclarationSpecifier() {
     return TPResult::True();
   }
 
-  // C++0x decltype support.
-  case tok::annot_decltype:
-    return TPResult::True();
-
   // C++0x type traits support
   case tok::kw___underlying_type:
     return TPResult::True();
diff --git a/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp b/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp
new file mode 100644
index 0000000..253744e
--- /dev/null
+++ b/test/CXX/expr/expr.post/expr.type.conv/p1-0x.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+struct foo {
+  foo();
+  foo(int);
+};
+
+int func(foo& f) {
+  decltype(foo())();
+  f = (decltype(foo()))5;
+  return decltype(3)(5);
+}
diff --git a/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp b/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp
new file mode 100644
index 0000000..81e8e25
--- /dev/null
+++ b/test/CXX/stmt.stmt/stmt.ambig/p1-0x.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+struct T { 
+  struct x {
+    int m;
+  };
+  x* operator->();
+  void operator++(int);
+  void operator<<(int);
+  T();
+  T(int);
+  T(int, int);
+};
+
+template<typename A, typename B, typename C, typename D, typename E>
+void func(A, B, C, D, E);
+
+void func(int a, int c) {
+  T(a)->m = 7;
+  T(a)++;
+  T(a,5)<<c;
+
+  T(*d)(int);
+  T(e)[5];
+  T(f) = {1, 2};
+  T(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'T (*)' with an rvalue of type 'double'}}
+  func(a, d, e, f, g);
+}
+
+void func2(int a, int c) {
+  decltype(T())(a)->m = 7;
+  decltype(T())(a)++;
+  decltype(T())(a,5)<<c;
+
+  decltype(T())(*d)(int);
+  decltype(T())(e)[5];
+  decltype(T())(f) = {1, 2};
+  decltype(T())(*g)(double(3)); // expected-error{{cannot initialize a variable of type 'decltype(T()) (*)' (aka 'T *') with an rvalue of type 'double'}}
+  func(a, d, e, f, g);
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to