[PATCH] D12686: Add support for GCC's '__auto_type' extension.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 11 18:46:14 PDT 2015


rsmith added a subscriber: rsmith.

================
Comment at: include/clang/AST/Type.h:1210
@@ +1209,3 @@
+/// Which keyword(s) were used to create an AutoType.
+enum struct AutoTypeKeyword : unsigned char {
+  /// \brief auto
----------------
Please use `enum class` here; we don't use `enum struct` anywhere in Clang or LLVM.

================
Comment at: include/clang/AST/Type.h:1216
@@ +1215,3 @@
+  /// \brief __auto_type (GNU extension)
+  AutoTypeExt
+};
----------------
Maybe `GNUAutoType`?

================
Comment at: include/clang/AST/Type.h:3915-3916
@@ -3902,5 +3914,4 @@
 
   void Profile(llvm::FoldingSetNodeID &ID) {
-    Profile(ID, getDeducedType(), isDecltypeAuto(), 
-		    isDependentType());
+    Profile(ID, getDeducedType(), AutoTypeBits.Keyword, isDependentType());
   }
----------------
`auto` and `__auto_type` should probably not profile differently; they mangle the same, so this will lead to mangling collisions. (It's not completely clear that we need to retain the distinction between `auto` and `__auto_type` here at all, since they have identical semantics, but it's probably a good thing for source fidelity. We don't maintain a difference between `bool` and `_Bool`, for what it's worth.)

================
Comment at: lib/Sema/SemaExpr.cpp:352
@@ -351,1 +351,3 @@
   if (ParsingInitForAutoVars.count(D)) {
+    const AutoType* AT = cast<VarDecl>(D)->getType().getTypePtr()->getContainedAutoType();
+
----------------
`const AutoType* AT` -> const AutoType *AT`. Also, remove the unnecessary `.getTypePtr()` here.

================
Comment at: test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp:4
@@ -3,3 +3,3 @@
 
 // FIXME: This is in p11 (?) in C++1y.
 void f() {
----------------
vsk wrote:
> Do you know what this FIXME alludes to? Seems rather mysterious to me.
It says that the relevant wording in the standard got moved to a different paragraph number (due to the insertion of more rules beforehand for deduced return types and generic lambdas).


http://reviews.llvm.org/D12686





More information about the cfe-commits mailing list