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

Nicholas Allegra via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 13 01:10:42 PDT 2015


comex added inline comments.

================
Comment at: lib/Sema/SemaType.cpp:2654-2655
@@ -2648,4 +2653,4 @@
     case Declarator::ConversionIdContext:
       if (!SemaRef.getLangOpts().CPlusPlus14)
-        Error = 12; // conversion-type-id
+        Error = 14; // conversion-type-id
       break;
----------------
rsmith wrote:
> Do you really want to allow `__auto_type` here? This is inconsistent with what you do for return types.
Also a mistake.

================
Comment at: test/SemaCXX/auto-type-from-cxx.cpp:14
@@ +13,3 @@
+  auto _ = [](__auto_type f) {}; // expected-error {{'__auto_type' not allowed in lambda parameter}}
+  __auto_type g = 2;
+  struct BitField { int field:2; };
----------------
thakis wrote:
> Shouldn't this say "warning: __auto_type is a gnu extension" (since this uses -std=c++14, not -std=gnu++14)?
Hmm... when I added `ext_auto_type` to the .td, I didn't notice the difference between Extension and ExtWarn.  Since the patch currently uses Extension, it won't warn by default, but will with `-pedantic`, `-Wgnu`, or `-Wgnu-auto-type`.  The C test uses `-pedantic` so it gets the warning.

Is there an explicit policy on which extensions should be ExtWarn?  Looking at the rest of that file, ExtWarns seem to be mostly either (a) standardized extensions (which will warn if `-std` is too early) and (b) 'extensions' that are more like "Clang will accept your buggy code" than features.  Most GNU extensions are just Extension, so I think it makes sense to do the same for `__auto_type`.

I could update the C++ test to add `-pedantic`, but arguably it makes more sense to test the fact that the warning is not emitted by default.


http://reviews.llvm.org/D12686





More information about the cfe-commits mailing list