Prechádzať zdrojové kódy

Features: Ensure that the cxx_auto_type test is correct.

SolarisStudio considers 'auto' to be a storage class specifier in
C++98 mode (as appropriate), and considers variables without a specified
type to be of type int.  So, it treats

 auto x = 3.14;

as

 auto int x = 3.14;

which in C++98 mode is equivalent to

 int x = 3.14;

and it does not fail to compile as expected.

Change the test to use a reference so that the type must be known.
Stephen Kelly 10 rokov pred
rodič
commit
69182ce4ed
1 zmenil súbory, kde vykonal 8 pridanie a 1 odobranie
  1. 8 1
      Tests/CompileFeatures/cxx_auto_type.cpp

+ 8 - 1
Tests/CompileFeatures/cxx_auto_type.cpp

@@ -1,5 +1,12 @@
 
+double foo_ = 3.14;
+
+double& foo()
+{
+  return foo_;
+}
+
 void someFunc()
 {
-  auto x = 3.14;
+  auto& x = foo();
 }