[cfe-dev] Updating the C++ dcl.spec.auto tests
Douglas Gregor
dgregor at apple.com
Mon Dec 20 21:51:58 PST 2010
On Dec 20, 2010, at 8:28 PM, Michael Price wrote:
> I've updated the tests for paragraph 3 of the [dcl.spec.auto] section of the latest standards draft.
>
> The patch is attached, and I'd greatly appreciate comments. I don't think it is ready to go in, but I'm not exactly sure why. I'm still somewhat new at this so please be gentle...
A couple comments...
-void f() {
- auto a = a; // expected-error{{variable 'a' declared with 'auto' type cannot appear in its own initializer}}
+
Where are you deleting this? The "auto in a block" tests need to be inside a function to work properly (?)
+// The name of the variable being declared shall not appear in the initializer expression
+//
+auto initializeWithSelf = initializeWithSelf; // expected-error{{variable 'initializeWithSelf' declared with 'auto' type cannot appear in its own initializer}}
it would be good to check a more interesting initializer, too, e.g.,
auto initializeWithSelf = 1 + &initializeWithSelf;
+// The use of auto is allowed when declaring variables in a for-init-statement
+//
+ for (auto iter = false; iter;)
+ ;
+
Also as the condition of for/if/while/switch statements, just for kicks.
+auto x = 5; // OK: x has type int
+const auto *v = &x, u = 6; // OK: v has type const int*, u has type const int
It would be good to check here that "v" actually has type "const int *", e.g., with
const int **vp = &v;
Eventually, we'll also needs tests for 'auto' within templates.
This is a good start. Thanks for working on this!
- Doug
More information about the cfe-dev
mailing list