tigerleapgorge created this revision.
tigerleapgorge added a reviewer: rsmith.
tigerleapgorge added a subscriber: cfe-commits.

24 tests have been updated for C++11 compatibility.


CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
  Ambiguous class member lookup has been fixed in C++11
  http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1111
  Restrict the following diagnostics to C++98.
    C++98: warning: lookup of 'set' in member access expression is ambiguous; 
using member of 'Value'
           note: lookup in the object type 'Value' refers here
           note: lookup from the current scope refers here

CXX/class/class.friend/p1.cpp
  Restrict the following diagnostics to C++98.
    C++98 error: friends cannot be members of the declaring class

CXX/class/class.friend/p2.cpp
  Restrict the following 2 diagnostics to C++98.
    C++98: warning: non-class friend type 'int' is a C++11 extension
    C++98: warning: unelaborated friend declaration is a C++11 extension; 
specify 'struct' to befriend 'B0'

CXX/stmt.stmt/stmt.dcl/p3.cpp
  Definition of POD has been relaxed in C++11 such that a struct with 
  a trivial copy assignment operator is still considered POD.

  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2294.html
  In the above paper, the following clause has been crossed out.
    “and has no user-declared copy assignment operator and no user-declared 
destructor” 

  For this test, struct Z is still a POD struct in C++11.
  Therefore goto can jump over Z’s instantiation without causing a compiler 
Error.
  Restrict the following to C++98
    C++98: error: cannot jump from this goto statement to its label
    C++98: note: jump bypasses initialization of non-POD variable

CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  C++11 accepts arbitrary literal types for non-type template parameters
    http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3413.html

  Change in diagnostics.
    C++98: error: non-type template argument for template parameter of pointer 
type 'int *' must have its address taken
    C++11: error: non-type template argument of type 'int' is not a constant 
expression
           note: read of non-const variable 'i' is not allowed in a constant 
expression
           note: declared here

  Restrict the following to C++98
    C++98: warning: non-type template argument referring to object 'ki' with 
internal linkage is a C++11 extension
           Note: non-type template argument refers to object here

  Change in diagnostics.
    C++98: error: non-type template argument refers to thread-local object
           note: non-type template argument refers here
    C++11: error: non-type template argument of type 'int *' is not a constant 
expression
           note: template parameter is declared here

  Restrict the following to C++98
    C++98: non-type template argument referring to function 'f_internal' with 
internal linkage is a C++11 extension
           note: non-type template argument refers to function here

  Change in diagnostics
    C++98: error: non-type template argument refers to object 'n' that does not 
have linkage
           note: non-type template argument refers to object here
    C++11: error: non-type template argument of type 'int *' is not a constant 
expression
           note: pointer to 'n' is not a constant expression
           note: declared here
           note: template parameter is declared here

  Change in diagnostics 
    C++98: error: non-type template argument for template parameter of pointer 
type 'int *' must have its address taken
    C++11: error: non-type template argument of type 'int *' is not a constant 
expression
           note: read of non-constexpr variable 'iptr' is not allowed in a 
constant expression
           note: declared here

CXX/temp/temp.arg/temp.arg.type/p2.cpp
  Unnamed types can now be used as template arguments in C++11
  http://stackoverflow.com/questions/5131691/what-is-an-unnamed-type-in-c
  Restrict the following diagnostics to C++98.
    C++98: Warning: template argument uses unnamed type

CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
  Template argument constant expression narrowing is not allowed.
    http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1809
  Restrict the following diagnostics to C++98.
    C++98:  error: call to 'f' is ambiguous
            note: candidate function
            note: candidate function

CXX/temp/temp.spec/no-body.cpp
  Explicit instantiation of a template inside a nested namespace is an Error in 
C++11.
  This could be the result of the following defect fix.
    http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#995

  Added 3 instances of the following diagnostics.
    C++11: error: explicit instantiation of 'x' must occur at global scope
           note: explicit instantiation refers here

  Also remove these 3 explicit instantiations from the -fixit runs.

CodeGenCXX/const-init.cpp
  Use constexpr instead of const in C++11 so the compiler does not complain.
    C++98: static const double d = 1.0;
    C++11: static constexpr double d = 1.0;

Parser/cxx-class.cpp
  Change in diagnostics for malformed class member definitions without 
parenthesis.
 In C++11, this looks like malformed initializer lists.
    C++98: error: function definition does not declare parameters
    C++11: error: expected expression
           error: expected '}'
           note: to match this '{'
           error: expected ';' after class
           error: extraneous closing brace

    C++98: error: function definition does not declare parameters
    C++11: error: variable has incomplete type 'void'
           error: expected ';' after top level declarator

  Restrict 6 instances of the following to C++98
    C++98: in-class initialization of non-static data member is a C++11 
extension

Parser/cxx-decl.cpp
  Restrict 1 instance of the following to C++98
    C++98: error: commas at the end of enumerator lists are a C++11 extension

  Restrict 2 instances of the following to C++98
    C++98: error: rvalue references are a C++11 extension

  Change in diagnostics as a result of attribute list in C++11
    C++98: error: expected expression
           error: expected unqualified-id
    C++11: error: an attribute list cannot appear here

  Restrict 1 instance of the following to C++98
    C++98: error: alias declarations are a C++11 extension

  Restrict 1 instance of the following to C++98
    C++98: error: 'template' keyword outside of a template

  Add 1 instance of the following to C++11
    C++11: error: 'friend' must appear first in a non-function declaration

  Change in diagnostics for unmatched braces at end of file.
    C++98: error: expected ';' after top level declarator
    C++11: error: expected expression
           error: expected '}'
           note: to match this '{'
           error: expected ';' after top level declarator

Parser/cxx-friend.cpp
  C++11 allows unelaborated friend declarations and non-class friend types.
  Restrict the following diagnostics to C++98.
    C++98: warning: unelaborated friend declaration is a C++11 extension; 
specify 'class' to befriend 'C'
    C++98: warning: unelaborated friend declaration is a C++11 extension; 
specify 'union' to befriend 'U'
    C++98: warning: non-class friend type 'int' is a C++11 extension

SemaCXX/anonymous-struct.cpp
  In C++11, struct member ‘x’ of type S is still POD since there is nothing in 
the constructor.
    http://www.stroustrup.com/C++11FAQ.html#PODs
  Restrict the following diagnostics to C++98.
    C++98: error: anonymous struct member 'x' has a non-trivial constructor
           note: because type 'S' has a user-provided default constructor

  C++11 allows unnamed types for template arguments
  Restrict the following diagnostics to C++98.
    C++98: warning: template argument uses unnamed type
           note: unnamed type used in template argument was declared here

SemaCXX/class.cpp
  Change in diagnostics regarding ‘auto’
    C++98: warning: 'auto' storage class specifier is redundant
    C++11: warning: 'auto' storage class specifier is not permitted in C++11, 
and will not be supported in future releases

  Restrict the following diagnostics to C++98.
    C++98: warning: in-class initialization of non-static data member is a 
C++11 extension

  Add the following diagnostics to C++11.
    C++11: error: static const volatile data member must be initialized out of 
line

  For the last part, slightly modify the test by changing const to constexpr 
for C++11
    in C++98 we still test for
      static const float x = 5.0f;
      static const float y = foo();

    in C++11 we test for
      static constexpr float x = 5.0f;
      static constexpr float y = foo();
      
    for the above C++11 case
      Assigning 5.0f to x no longer issues any diagnostics.
      Assigning foo’s return to y generates the following diagnostics.
        C++11: error: constexpr variable 'y' must be initialized by a constant 
expression
               error: constexpr variable 'y' must be initialized by a constant 
expression
               note: declared here

SemaCXX/conversion-function.cpp
  Diagnostic wordings changed from C++98 to C++11
   2 Changes in diagnostics between C++98 and C++11
      C++98: warning: C++98 requires an accessible copy constructor for class 
'A1' 
             when binding a reference to a temporary; was private 
[-Wbind-to-temporary-copy]
      C++11: warning: copying parameter of type 'A1' when binding a reference 
to a 
             temporary would invoke an inaccessible constructor in C++98 
[-Wc++98-compat-bind-to-temporary-copy]

      C++98: error: cannot specify any part of a return type in the declaration 
of a conversion function
      C++11: error: cannot specify any part of a return type in the declaration 
of a conversion function; 
                    use an alias template to declare a conversion to 'T (&)()'

   1 extra note diagnostics for move candidate constructor.
     C++11: note: candidate constructor (the implicit move constructor) not 
viable: 
                   no known conversion from 'smart_ptr::Y' to 'smart_ptr::X &&' 
for 1st argument

    1 Change in diagnostics wording non-POD became non-trivial
     C++98: error: cannot pass object of non-POD type 'Other' through variadic 
constructor; call will abort at runtim
      C++11: error: cannot pass object of non-trivial type 'Other' through 
variadic constructor; call will abort at runtim

SemaCXX/cxx1y-variable-templates_in_class.cpp
SemaCXX/cxx1y-variable-templates_top_level.cpp
  These 2 tests check for variable template support in 3 dialects:
   C++98, C++11 and C++14
  Since the first run line of each test specifically test for pre C++11 
behavior, 
  simply add –std=c++98 to the first RUN line.

SemaCXX/exceptions.cpp
  C++11 no longer issues an error regarding pointer to incomplete type inside 
throw().
  This appears valid since dynamic exception specifications aka throw() has 
been deprecated.
  And that “parameter packs are allowed in C++11.”
    http://en.cppreference.com/w/cpp/language/except_spec
  Restrict the following group of 3 diagnostics to C++98
    C++98: error: pointer to incomplete type 'Decay::E' is not allowed in 
exception specification
           note: in instantiation of template class 'Decay::C<Decay::E [10]>' 
requested here
           note: forward declaration of 'Decay::E'

  Also, restrict the rvalue reference diagnostics to C++98.
    C++98: warning: rvalue references are a C++11 extension

SemaCXX/qual-id-test.cpp
  Ambiguous class member lookup has been fixed in C++11
  Restrict the following diagnostics to C++98.
    C++98: error: lookup of 'base' in member access expression is ambiguous
           note: lookup in the object type 'A::sub' refers here
           note: lookup from the current scope refers here

SemaCXX/unused.cpp
  In C++11, volatile-qualified lvalue undergoes lvalue-to-rvalue conversion 
inside discared-value expressions.
  The statement *x; is a discared-value expression of a lvalue of an 
indirection.
  Therefore *x; considered a use of x in C++11.
  http://open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1054
  
http://stackoverflow.com/questions/20242868/correct-behaviour-of-trivial-statements-involving-expressions-with-volatile-vari

  Restrict the following diagnostics to C++98.
    C++98: warning: expression result unused; assign into a variable to force a 
volatile load

SemaCXX/warn-unused-value.cpp
  Simular to previous test case, volatile in a discared-value expression is now 
a use in C++11
  Restrict the following diagnostics to C++98.
    C++98: warning: expression result unused; assign into a variable to force a 
volatile load

SemaTemplate/member-access-expr.cpp
  Ambiguous class member lookup has been fixed in C++11
    http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1111
  Restrict the following diagnostics to C++98.
    C++98: error: lookup of 'CrazyBase' in member access expression is ambiguous
           note: lookup in the object type 'X1' refers here
           note: lookup from the current scope refers here

SemaTemplate/recovery-crash.cpp
  C++11 allows the use of local types as template arguments.
  Restrict the following diagnostics to C++98.
    C++98: warning: template argument uses local type 'LocalStruct'
           note: in instantiation of function template specialization

SemaTemplate/temp_arg_type.cpp
  C++11 allows both local type and unnamed type to be used in template 
arguments.
  Restrict the following diagnostics to C++98.
    C++98: warning: template argument uses local type 'X'
    C++98: warning: template argument uses unnamed type
           note: unnamed type used in template argument was declared here


http://reviews.llvm.org/D19131

Files:
  CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
  CXX/class/class.friend/p1.cpp
  CXX/class/class.friend/p2.cpp
  CXX/stmt.stmt/stmt.dcl/p3.cpp
  CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  CXX/temp/temp.arg/temp.arg.type/p2.cpp
  CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
  CXX/temp/temp.spec/no-body.cpp
  CodeGenCXX/const-init.cpp
  Parser/cxx-class.cpp
  Parser/cxx-decl.cpp
  Parser/cxx-friend.cpp
  SemaCXX/anonymous-struct.cpp
  SemaCXX/class.cpp
  SemaCXX/conversion-function.cpp
  SemaCXX/cxx1y-variable-templates_in_class.cpp
  SemaCXX/cxx1y-variable-templates_top_level.cpp
  SemaCXX/exceptions.cpp
  SemaCXX/qual-id-test.cpp
  SemaCXX/unused.cpp
  SemaCXX/warn-unused-value.cpp
  SemaTemplate/member-access-expr.cpp
  SemaTemplate/recovery-crash.cpp
  SemaTemplate/temp_arg_type.cpp

Index: SemaTemplate/temp_arg_type.cpp
===================================================================
--- SemaTemplate/temp_arg_type.cpp
+++ SemaTemplate/temp_arg_type.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
 template<typename T> class A; // expected-note 2 {{template parameter is declared here}} expected-note{{template is declared here}}
 
 // [temp.arg.type]p1
@@ -24,11 +27,21 @@
 // [temp.arg.type]p2
 void f() {
   class X { };
-  A<X> * a = 0; // expected-warning{{template argument uses local type 'X'}}
+  A<X> * a = 0;
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{template argument uses local type 'X'}}
+#endif
 }
 
-struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}}
-A<__typeof__(Unnamed)> *a9; // expected-warning{{template argument uses unnamed type}}
+struct { int x; } Unnamed;
+#if __cplusplus <= 199711L
+// expected-note@-2 {{unnamed type used in template argument was declared here}}
+#endif
+
+A<__typeof__(Unnamed)> *a9;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{template argument uses unnamed type}}
+#endif
 
 template<typename T, unsigned N>
 struct Array {
Index: SemaTemplate/recovery-crash.cpp
===================================================================
--- SemaTemplate/recovery-crash.cpp
+++ SemaTemplate/recovery-crash.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 // Clang used to crash trying to recover while adding 'this->' before Work(x);
 
@@ -25,14 +27,20 @@
 
 namespace PR16225 {
   template <typename T> void f();
-  template<typename C> void g(C*) {
+  template <typename C> void g(C*) {
     struct LocalStruct : UnknownBase<Mumble, C> { };  // expected-error {{unknown template name 'UnknownBase'}} \
                                                       // expected-error {{use of undeclared identifier 'Mumble'}}
-    f<LocalStruct>();  // expected-warning {{template argument uses local type 'LocalStruct'}}
+    f<LocalStruct>();
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{template argument uses local type 'LocalStruct'}}
+#endif
   }
   struct S;
   void h() {
-    g<S>(0);  // expected-note {{in instantiation of function template specialization}}
+    g<S>(0);
+#if __cplusplus <= 199711L
+    // expected-note@-2 {{in instantiation of function template specialization}}
+#endif
   }
 }
 
Index: SemaTemplate/member-access-expr.cpp
===================================================================
--- SemaTemplate/member-access-expr.cpp
+++ SemaTemplate/member-access-expr.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
 template<typename T>
 void call_f0(T x) {
   x.Base::f0();
@@ -28,15 +31,25 @@
 
 template<typename TheBase, typename T>
 void call_f0_through_typedef2(T x) {
-  typedef TheBase CrazyBase; // expected-note{{current scope}}
-  x.CrazyBase::f0(); // expected-error{{ambiguous}} \
-                     // expected-error 2{{no member named}}
+  typedef TheBase CrazyBase;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{lookup from the current scope refers here}}
+#endif
+
+  x.CrazyBase::f0(); // expected-error 2{{no member named}}
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{lookup of 'CrazyBase' in member access expression is ambiguous}}
+#endif
+
 }
 
 struct OtherBase { };
 
 struct X1 : Base, OtherBase { 
-  typedef OtherBase CrazyBase; // expected-note{{object type}}
+  typedef OtherBase CrazyBase;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{lookup in the object type 'X1' refers here}}
+#endif
 };
 
 void test_f0_through_typedef2(X0 x0, X1 x1) {
Index: SemaCXX/warn-unused-value.cpp
===================================================================
--- SemaCXX/warn-unused-value.cpp
+++ SemaCXX/warn-unused-value.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wunused-value -std=c++11 %s
 
 // PR4806
 namespace test0 {
@@ -12,7 +14,10 @@
     // pointer to volatile has side effect (thus no warning)
     Box* box = new Box;
     box->i; // expected-warning {{expression result unused}}
-    box->j; // expected-warning {{expression result unused}}
+    box->j;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{expression result unused}}
+#endif
   }
 }
 
Index: SemaCXX/unused.cpp
===================================================================
--- SemaCXX/unused.cpp
+++ SemaCXX/unused.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 // PR4103 : Make sure we don't get a bogus unused expression warning
 namespace PR4103 {
@@ -28,8 +30,14 @@
 
 namespace derefvolatile {
   void f(volatile char* x) {
-    *x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}}
-    (void)*x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}}
+    *x;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{expression result unused; assign into a variable to force a volatile load}}
+#endif
+    (void)*x;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{expression result unused; assign into a variable to force a volatile load}}
+#endif
     volatile char y = 10;
     (void)y; // don't warn here, because it's a common pattern.
   }
Index: SemaCXX/qual-id-test.cpp
===================================================================
--- SemaCXX/qual-id-test.cpp
+++ SemaCXX/qual-id-test.cpp
@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s 
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
 namespace A
 {
     namespace B
     {
-        struct base // expected-note{{object type}}
+        struct base
+#if __cplusplus <= 199711L
+        // expected-note@-2 {{lookup in the object type 'A::sub' refers here}}
+#endif
         {
             void x() {}
             void y() {}
@@ -85,8 +91,14 @@
     void fun4a() {
       A::sub *a;
       
-      typedef A::member base; // expected-note{{current scope}}
-      a->base::x(); // expected-error{{ambiguous}}      
+      typedef A::member base;
+#if __cplusplus <= 199711L
+      // expected-note@-2 {{lookup from the current scope refers here}}
+#endif
+      a->base::x();
+#if __cplusplus <= 199711L
+      // expected-error@-2 {{lookup of 'base' in member access expression is ambiguous}}
+#endif
     }
 
     void fun4b() {
Index: SemaCXX/exceptions.cpp
===================================================================
--- SemaCXX/exceptions.cpp
+++ SemaCXX/exceptions.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s
 
 struct A; // expected-note 4 {{forward declaration of 'A'}}
 
@@ -135,16 +137,29 @@
   void f() throw (int*, int());
 
   template<typename T> struct C {
-    void f() throw (T); // expected-error {{pointer to incomplete type 'Decay::E' is not allowed in exception specification}}
+    void f() throw (T);
+#if __cplusplus <= 199711L
+    // expected-error@-2 {{pointer to incomplete type 'Decay::E' is not allowed in exception specification}}
+#endif
   };
   struct D {
     C<D[10]> c;
   };
-  struct E; // expected-note {{forward declaration}}
-  C<E[10]> e; // expected-note {{in instantiation of}}
+  struct E;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{forward declaration of 'Decay::E'}}
+#endif
+
+  C<E[10]> e;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{in instantiation of template class 'Decay::C<Decay::E [10]>' requested here}}
+#endif
 }
 
-void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}} expected-warning {{C++11}}
+void rval_ref() throw (int &&); // expected-error {{rvalue reference type 'int &&' is not allowed in exception specification}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{rvalue references are a C++11 extension}}
+#endif
 
 namespace HandlerInversion {
 struct B {};
Index: SemaCXX/cxx1y-variable-templates_top_level.cpp
===================================================================
--- SemaCXX/cxx1y-variable-templates_top_level.cpp
+++ SemaCXX/cxx1y-variable-templates_top_level.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only -Wno-c++11-extensions -Wno-c++1y-extensions %s -DPRECXX11
+// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only -Wno-c++11-extensions -Wno-c++1y-extensions %s -DPRECXX11
 // RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s
 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s
 
Index: SemaCXX/cxx1y-variable-templates_in_class.cpp
===================================================================
--- SemaCXX/cxx1y-variable-templates_in_class.cpp
+++ SemaCXX/cxx1y-variable-templates_in_class.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11
+// RUN: %clang_cc1 -std=c++98 -verify -fsyntax-only %s -Wno-c++11-extensions -Wno-c++1y-extensions -DPRECXX11
 // RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only -Wno-c++1y-extensions %s
 // RUN: %clang_cc1 -std=c++1y -verify -fsyntax-only %s -DCPP1Y
 
Index: SemaCXX/conversion-function.cpp
===================================================================
--- SemaCXX/conversion-function.cpp
+++ SemaCXX/conversion-function.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify %s 
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++98 %s
+// RUN: %clang_cc1 -triple %itanium_abi_triple -fsyntax-only -Wbind-to-temporary-copy -verify -std=c++11 %s
+
 class X { 
 public:
   operator bool();
@@ -133,7 +136,12 @@
 
 A1 f() {
   // FIXME: redundant diagnostics!
-  return "Hello"; // expected-error {{calling a private constructor}} expected-warning {{an accessible copy constructor}}
+  return "Hello"; // expected-error {{calling a private constructor}}
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{an accessible copy constructor}}
+#else
+  // expected-warning@-4 {{copying parameter of type 'A1' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}}
+#endif
 }
 
 namespace source_locations {
@@ -175,7 +183,13 @@
     (&operator bool())(); // expected-error {{use a typedef to declare a conversion to 'bool (&)()'}}
     *operator int();  // expected-error {{put the complete type after 'operator'}}
     // No suggestion of using a typedef here; that's not possible.
-    template<typename T> (&operator T())(); // expected-error-re {{cannot specify any part of a return type in the declaration of a conversion function{{$}}}}
+    template<typename T> (&operator T())();
+#if __cplusplus <= 199711L
+    // expected-error-re@-2 {{cannot specify any part of a return type in the declaration of a conversion function{{$}}}}
+#else
+    // expected-error-re@-4 {{cannot specify any part of a return type in the declaration of a conversion function; use an alias template to declare a conversion to 'T (&)()'{{$}}}}
+#endif
+
   };
 }
 
@@ -193,6 +207,10 @@
   };
 
   struct X { // expected-note{{candidate constructor (the implicit copy constructor) not}}
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not}}
+#endif
+
     explicit X(Y);
   };
 
@@ -215,7 +233,12 @@
 };
 
 void test_any() {
-  Any any = Other(); // expected-error{{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}}
+  Any any = Other();
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{cannot pass object of non-POD type 'Other' through variadic constructor; call will abort at runtime}}
+#else
+  // expected-error@-4 {{cannot pass object of non-trivial type 'Other' through variadic constructor; call will abort at runtime}}
+#endif
 }
 
 namespace PR7055 {
Index: SemaCXX/class.cpp
===================================================================
--- SemaCXX/class.cpp
+++ SemaCXX/class.cpp
@@ -1,7 +1,12 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s 
 class C {
 public:
-  auto int errx; // expected-error {{storage class specified for a member declaration}} expected-warning {{'auto' storage class specifier is redundant}}
+  auto int errx; // expected-error {{storage class specified for a member declaration}}
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{'auto' storage class specifier is redundant}}
+#else
+  // expected-warning@-4 {{'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases}}
+#endif
   register int erry; // expected-error {{storage class specified for a member declaration}}
   extern int errz; // expected-error {{storage class specified for a member declaration}}
 
@@ -36,12 +41,18 @@
 
   enum E1 { en1, en2 };
 
-  int i = 0; // expected-warning {{in-class initialization of non-static data member is a C++11 extension}}
+  int i = 0;
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
   static int si = 0; // expected-error {{non-const static data member must be initialized out of line}}
   static const NestedC ci = 0; // expected-error {{static data member of type 'const C::NestedC' must be initialized out of line}}
   static const int nci = vs; // expected-error {{in-class initializer for static data member is not a constant expression}}
   static const int vi = 0;
   static const volatile int cvi = 0; // ok, illegal in C++11
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{static const volatile data member must be initialized out of line}}
+#endif
   static const E evi = 0;
 
   void m() {
@@ -169,10 +180,18 @@
 
 namespace rdar8367341 {
   float foo();
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{declared here}}
+#endif
 
   struct A {
+#if __cplusplus <= 199711L
     static const float x = 5.0f; // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}}
     static const float y = foo(); // expected-warning {{in-class initializer for static data member of type 'const float' is a GNU extension}} expected-error {{in-class initializer for static data member is not a constant expression}}
+#else
+    static constexpr float x = 5.0f;
+    static constexpr float y = foo(); // expected-error {{constexpr variable 'y' must be initialized by a constant expression}} expected-note {{non-constexpr function 'foo' cannot be used in a constant expression}}
+#endif
   };
 }
 
Index: SemaCXX/anonymous-struct.cpp
===================================================================
--- SemaCXX/anonymous-struct.cpp
+++ SemaCXX/anonymous-struct.cpp
@@ -1,23 +1,38 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct S {
-  S();  // expected-note {{because type 'S' has a user-provided default constructor}}
+  S();
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{because type 'S' has a user-provided default constructor}}
+#endif
 };
 
 struct { // expected-error {{anonymous structs and classes must be class members}}
 };
 
 struct E {
   struct {
-    S x;  // expected-error {{anonymous struct member 'x' has a non-trivial constructor}}
+    S x;
+#if __cplusplus <= 199711L
+    // expected-error@-2 {{anonymous struct member 'x' has a non-trivial constructor}}
+#endif
   };
   static struct {
   };
 };
 
 template <class T> void foo(T);
-typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}} expected-note {{declared here}}
+typedef struct { // expected-note {{use a tag name here to establish linkage prior to definition}}
+#if __cplusplus <= 199711L
+// expected-note@-2 {{declared here}}
+#endif
+
   void test() {
-    foo(this); // expected-warning {{template argument uses unnamed type}}
+    foo(this);
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{template argument uses unnamed type}}
+#endif
   }
 } A; // expected-error {{unsupported: typedef changes linkage of anonymous type, but linkage was already computed}}
Index: Parser/cxx-friend.cpp
===================================================================
--- Parser/cxx-friend.cpp
+++ Parser/cxx-friend.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 class C {
   friend class D;
@@ -21,9 +23,20 @@
   // 'A' here should refer to the declaration above.  
   friend class A;
 
-  friend C; // expected-warning {{specify 'class' to befriend}}
-  friend U; // expected-warning {{specify 'union' to befriend}}
-  friend int; // expected-warning {{non-class friend type 'int'}}
+  friend C;
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'class' to befriend 'C'}}
+#endif
+
+  friend U;
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'union' to befriend 'U'}}
+#endif
+
+  friend int;
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{non-class friend type 'int' is a C++11 extension}}
+#endif
 
   friend void myfunc();
 
Index: Parser/cxx-decl.cpp
===================================================================
--- Parser/cxx-decl.cpp
+++ Parser/cxx-decl.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions -std=c++98 %s
+// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic-errors -fcxx-exceptions -fexceptions -std=c++11 %s
 
 const char const *x10; // expected-error {{duplicate 'const' declaration specifier}}
 
@@ -46,7 +48,10 @@
   void foo() __asm__("baz");
 };
 
-enum { fooenum = 1, }; // expected-error {{commas at the end of enumerator lists are a C++11 extension}}
+enum { fooenum = 1, };
+#if __cplusplus <= 199711L
+// expected-error@-2 {{commas at the end of enumerator lists are a C++11 extension}}
+#endif
 
 struct a {
   int Type : fooenum;
@@ -81,7 +86,11 @@
   (global5),
   *global6,
   &global7 = global1,
-  &&global8 = static_cast<int&&>(global1), // expected-error 2{{rvalue reference}}
+  &&global8 = static_cast<int&&>(global1),
+#if __cplusplus <= 199711L
+  // expected-error@-2 2{{rvalue references are a C++11 extension}}
+#endif
+
   S::a,
   global9,
   global10 = 0,
@@ -185,7 +194,13 @@
 }
 
 // Ensure we produce at least some diagnostic for attributes in C++98.
-[[]] struct S; // expected-error 2{{}}
+[[]] struct S;
+#if __cplusplus <= 199711L
+// expected-error@-2 {{expected expression}}
+// expected-error@-3 {{expected unqualified-id}}
+#else
+// expected-error@-5 {{an attribute list cannot appear here}}
+#endif
 
 namespace test7 {
   struct Foo {
@@ -212,14 +227,20 @@
   template<typename T> struct X {};
   X<int N> x; // expected-error {{type-id cannot have a name}}
 
-  using T = int (*T)(); // expected-error {{type-id cannot have a name}} expected-error {{C++11}}
+  using T = int (*T)(); // expected-error {{type-id cannot have a name}}
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{alias declarations are a C++11 extensio}}
+#endif
+
 }
 
 namespace PR17255 {
 void foo() {
-  typename A::template B<>; // expected-error {{use of undeclared identifier 'A'}} \
-                            // expected-error {{expected a qualified name after 'typename'}} \
-                            // expected-error {{'template' keyword outside of a template}}
+  typename A::template B<>; // expected-error {{use of undeclared identifier 'A'}}
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{'template' keyword outside of a template}}
+#endif
+  // expected-error@-4 {{expected a qualified name after 'typename'}}
 }
 }
 
@@ -236,12 +257,25 @@
   struct A {
     friend void friend f(); // expected-warning {{duplicate 'friend' declaration specifier}}
     friend struct B friend; // expected-warning {{duplicate 'friend' declaration specifier}}
+#if __cplusplus >= 201103L
+    // expected-error@-2 {{'friend' must appear first in a non-function declaration}}
+#endif
   };
 }
 
 // PR8380
 extern ""      // expected-error {{unknown linkage language}}
-test6a { ;// expected-error {{C++ requires a type specifier for all declarations}} \
-     // expected-error {{expected ';' after top level declarator}}
+test6a { ;// expected-error {{C++ requires a type specifier for all declarations}}
+#if __cplusplus <= 199711L
+// expected-error@-2 {{expected ';' after top level declarator}}
+#else
+// expected-error@-4 {{expected expression}}
+// expected-note@-5 {{to match this}}
+#endif
   
   int test6b;
+#if __cplusplus >= 201103L
+// expected-error@+3 {{expected}}
+// expected-error@-3 {{expected ';' after top level declarator}}
+#endif
+
Index: Parser/cxx-class.cpp
===================================================================
--- Parser/cxx-class.cpp
+++ Parser/cxx-class.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -fcxx-exceptions -std=c++11 %s
+
 class C;
 class C {
 public:
@@ -69,11 +72,30 @@
 };
 
 class F {
-    int F1 { return 1; } // expected-error{{function definition does not declare parameters}}
-    void F2 {} // expected-error{{function definition does not declare parameters}}
+    int F1 { return 1; }
+#if __cplusplus <= 199711L
+    // expected-error@-2 {{function definition does not declare parameters}}
+#else
+    // expected-error@-4 {{expected expression}}
+    // expected-error@-5 {{expected}}
+    // expected-note@-6 {{to match this '{'}}
+    // expected-error@-7 {{expected ';' after class}}
+#endif
+
+    void F2 {}
+#if __cplusplus <= 199711L
+    // expected-error@-2 {{function definition does not declare parameters}}
+#else
+    // expected-error@-4 {{variable has incomplete type 'void'}}
+    // expected-error@-5 {{expected ';' after top level declarator}}
+#endif
+
     typedef int F3() { return 0; } // expected-error{{function definition declared 'typedef'}}
     typedef void F4() {} // expected-error{{function definition declared 'typedef'}}
 };
+#if __cplusplus >= 201103L
+// expected-error@-2 {{extraneous closing brace}}
+#endif
 
 namespace ctor_error {
   class Foo {};
@@ -203,14 +225,38 @@
 }
 
 class PR20760_a {
-  int a = ); // expected-warning {{extension}} expected-error {{expected expression}}
-  int b = }; // expected-warning {{extension}} expected-error {{expected expression}}
-  int c = ]; // expected-warning {{extension}} expected-error {{expected expression}}
+  int a = ); // expected-error {{expected expression}}
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
+  int b = }; // expected-error {{expected expression}}
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
+  int c = ]; // expected-error {{expected expression}}
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
 };
 class PR20760_b {
-  int d = d); // expected-warning {{extension}} expected-error {{expected ';'}}
-  int e = d]; // expected-warning {{extension}} expected-error {{expected ';'}}
-  int f = d // expected-warning {{extension}} expected-error {{expected ';'}}
+  int d = d); // expected-error {{expected ';'}}
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
+  int e = d]; // expected-error {{expected ';'}}
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
+  int f = d // expected-error {{expected ';'}}
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{in-class initialization of non-static data member is a C++11 extension}}
+#endif
+
 };
 
 namespace PR20887 {
Index: CodeGenCXX/const-init.cpp
===================================================================
--- CodeGenCXX/const-init.cpp
+++ CodeGenCXX/const-init.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -std=c++98 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -std=c++11 -o - %s | FileCheck %s
 
 // CHECK: @a = global i32 10
 int a = 10;
@@ -27,8 +29,13 @@
 
 namespace test2 {
   struct A {
+#if __cplusplus <= 199711L
     static const double d = 1.0;
     static const float f = d / 2;
+#else
+    static constexpr double d = 1.0;
+    static constexpr float f = d / 2;
+#endif
     static int g();
   } a;
 
Index: CXX/temp/temp.spec/no-body.cpp
===================================================================
--- CXX/temp/temp.spec/no-body.cpp
+++ CXX/temp/temp.spec/no-body.cpp
@@ -1,17 +1,44 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -x c++ -fixit %t -DFIXING
 // RUN: %clang_cc1 -x c++ %t -DFIXING
 
 template<typename T> void f(T) { }
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{explicit instantiation refers here}}
+#endif
+
 template<typename T> void g(T) { }
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{explicit instantiation refers here}}
+#endif
+
 template<typename T> struct x { };
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{explicit instantiation refers here}}
+#endif
+
 template<typename T> struct y { };  // expected-note {{declared here}}
 
-namespace good {
+namespace good { // Only good in C++98/03
+#ifndef FIXING
   template void f<int>(int);
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{explicit instantiation of 'f' must occur at global scope}}
+#endif
+
   template void g(int);
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{explicit instantiation of 'g' must occur at global scope}}
+#endif
+
   template struct x<int>;
+#if __cplusplus >= 201103L
+  // expected-error@-2 {{explicit instantiation of 'x' must occur at global scope}}
+#endif
+#endif
 }
 
 namespace unsupported {
Index: CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
===================================================================
--- CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
+++ CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
@@ -1,9 +1,22 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
-template <int> int f(int);  // expected-note 2{{candidate}}
-template <signed char> int f(int); // expected-note 2{{candidate}}
-int i1 = f<1>(0); // expected-error{{ambiguous}}
-int i2 = f<1000>(0); // expected-error{{ambiguous}}
+template <int> int f(int);  // expected-note {{candidate function}}
+#if __cplusplus <= 199711L
+// expected-note@-2 {{candidate function}}
+#endif
+
+template <signed char> int f(int); // expected-note {{candidate function}}
+#if __cplusplus <= 199711L
+// expected-note@-2 {{candidate function}}
+#endif
+
+int i1 = f<1>(0); // expected-error{{call to 'f' is ambiguous}}
+int i2 = f<1000>(0);
+#if __cplusplus <= 199711L
+// expected-error@-2{{call to 'f' is ambiguous}}
+#endif
 
 namespace PR6707 {
   template<typename T, T Value>
Index: CXX/temp/temp.arg/temp.arg.type/p2.cpp
===================================================================
--- CXX/temp/temp.arg/temp.arg.type/p2.cpp
+++ CXX/temp/temp.arg/temp.arg.type/p2.cpp
@@ -1,4 +1,7 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
 template<class T> struct A {
   static T t; // expected-error{{static data member instantiated with function type 'int ()'}}
 };
@@ -11,32 +14,69 @@
 B<function> b; // expected-note{{instantiation of}}
 
 template <typename T> int f0(void *, const T&); // expected-note{{candidate template ignored: substitution failure}}
-enum {e}; // expected-note{{unnamed type used in template argument was declared here}}
+enum {e};
+#if __cplusplus <= 199711L
+// expected-note@-2 {{unnamed type used in template argument was declared here}}
+#endif
 
 void test_f0(int n) {
-  int i = f0(0, e); // expected-warning{{template argument uses unnamed type}}
+  int i = f0(0, e);
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{template argument uses unnamed type}}
+#endif
+
   int vla[n];
   f0(0, vla); // expected-error{{no matching function for call to 'f0'}}
 }
 
 namespace N0 {
   template <typename R, typename A1> void f0(R (*)(A1));
   template <typename T> int f1(T);
   template <typename T, typename U> int f1(T, U);
-  enum {e1}; // expected-note 2{{unnamed type used in template argument was declared here}}
-  enum {e2}; // expected-note 2{{unnamed type used in template argument was declared here}}
-  enum {e3}; // expected-note{{unnamed type used in template argument was declared here}}
+  enum {e1};
+#if __cplusplus <= 199711L
+  // expected-note@-2 2{{unnamed type used in template argument was declared here}}
+#endif
+
+  enum {e2};
+#if __cplusplus <= 199711L
+  // expected-note@-2 2{{unnamed type used in template argument was declared here}}
+#endif
+
+  enum {e3};
+#if __cplusplus <= 199711L
+ // expected-note@-2 {{unnamed type used in template argument was declared here}}
+#endif
 
   template<typename T> struct X;
   template<typename T> struct X<T*> { };
 
   void f() {
-    f0( // expected-warning{{template argument uses unnamed type}}
-       &f1<__typeof__(e1)>); // expected-warning{{template argument uses unnamed type}}
-    int (*fp1)(int, __typeof__(e2)) = f1; // expected-warning{{template argument uses unnamed type}}
-    f1(e2); // expected-warning{{template argument uses unnamed type}}
+    f0(
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{template argument uses unnamed type}}
+#endif
+
+       &f1<__typeof__(e1)>);
+#if __cplusplus <= 199711L
+ // expected-warning@-2 {{template argument uses unnamed type}}
+#endif
+
+    int (*fp1)(int, __typeof__(e2)) = f1;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{template argument uses unnamed type}}
+#endif
+
+    f1(e2);
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{template argument uses unnamed type}}
+#endif
+
     f1(e2);
 
-    X<__typeof__(e3)*> x; // expected-warning{{template argument uses unnamed type}}
+    X<__typeof__(e3)*> x;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{template argument uses unnamed type}}
+#endif
   }
 }
Index: CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
===================================================================
--- CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
+++ CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple=x86_64-linux-gnu -std=c++11 %s
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -triple=x86_64-linux-gnu %s -DCPP11ONLY
 
 // C++11 [temp.arg.nontype]p1:
@@ -31,55 +33,135 @@
 //      if the corresopnding template-parameter is a reference; or
 namespace addr_of_obj_or_func {
   template <int* p> struct X0 { }; // expected-note 5{{here}}
+#if __cplusplus >= 201103L
+  // expected-note@-2 2{{template parameter is declared here}}
+#endif
+
   template <int (*fp)(int)> struct X1 { };
   template <int &p> struct X2 { }; // expected-note 4{{here}}
   template <const int &p> struct X2k { }; // expected-note {{here}}
   template <int (&fp)(int)> struct X3 { }; // expected-note 4{{here}}
 
   int i = 42;
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{declared here}}
+#endif
+
   int iarr[10];
   int f(int i);
-  const int ki = 9; // expected-note 5{{here}}
-  __thread int ti = 100; // expected-note 2{{here}}
-  static int f_internal(int); // expected-note 4{{here}}
+  const int ki = 9;
+#if __cplusplus <= 199711L
+  // expected-note@-2 5{{non-type template argument refers to object here}}
+#endif
+
+  __thread int ti = 100; // expected-note {{here}}
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{here}}
+#endif
+
+  static int f_internal(int);
+#if __cplusplus <= 199711L
+  // expected-note@-2 4{{non-type template argument refers to function here}}
+#endif
+
   template <typename T> T f_tmpl(T t);
   struct S { union { int NonStaticMember; }; };
 
   void test() {
-    X0<i> x0a; // expected-error {{must have its address taken}}
+    X0<i> x0a;
+#if __cplusplus <= 199711L
+    // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}}
+#else
+    // expected-error@-4 {{non-type template argument of type 'int' is not a constant expression}}
+    // expected-note@-5 {{read of non-const variable 'i' is not allowed in a constant expression}}
+#endif
     X0<&i> x0a_addr;
     X0<iarr> x0b;
     X0<&iarr> x0b_addr; // expected-error {{cannot be converted to a value of type 'int *'}}
-    X0<ki> x0c; // expected-error {{must have its address taken}} expected-warning {{internal linkage is a C++11 extension}}
-    X0<&ki> x0c_addr; // expected-error {{cannot be converted to a value of type 'int *'}} expected-warning {{internal linkage is a C++11 extension}}
-    X0<&ti> x0d_addr; // expected-error {{refers to thread-local object}}
+    X0<ki> x0c; // expected-error {{must have its address taken}}
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
+    X0<&ki> x0c_addr; // expected-error {{cannot be converted to a value of type 'int *'}}
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
+    X0<&ti> x0d_addr;
+#if __cplusplus <= 199711L
+    // expected-error@-2 {{non-type template argument refers to thread-local object}}
+#else
+    // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}}
+#endif
+
     X1<f> x1a;
     X1<&f> x1a_addr;
     X1<f_tmpl> x1b;
     X1<&f_tmpl> x1b_addr;
     X1<f_tmpl<int> > x1c;
     X1<&f_tmpl<int> > x1c_addr;
-    X1<f_internal> x1d; // expected-warning {{internal linkage is a C++11 extension}}
-    X1<&f_internal> x1d_addr; // expected-warning {{internal linkage is a C++11 extension}}
+    X1<f_internal> x1d;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
+    X1<&f_internal> x1d_addr;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
     X2<i> x2a;
     X2<&i> x2a_addr; // expected-error {{address taken}}
     X2<iarr> x2b; // expected-error {{cannot bind to template argument of type 'int [10]'}}
     X2<&iarr> x2b_addr; // expected-error {{address taken}}
-    X2<ki> x2c; // expected-error {{ignores qualifiers}} expected-warning {{internal linkage is a C++11 extension}}
-    X2k<ki> x2kc; // expected-warning {{internal linkage is a C++11 extension}}
-    X2k<&ki> x2kc_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}}
+    X2<ki> x2c; // expected-error {{ignores qualifiers}}
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
+    X2k<ki> x2kc;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
+    X2k<&ki> x2kc_addr; // expected-error {{address taken}}
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
     X2<ti> x2d_addr; // expected-error {{refers to thread-local object}}
     X3<f> x3a;
     X3<&f> x3a_addr; // expected-error {{address taken}}
     X3<f_tmpl> x3b;
     X3<&f_tmpl> x3b_addr; // expected-error {{address taken}}
     X3<f_tmpl<int> > x3c;
     X3<&f_tmpl<int> > x3c_addr; // expected-error {{address taken}}
-    X3<f_internal> x3d; // expected-warning {{internal linkage is a C++11 extension}}
-    X3<&f_internal> x3d_addr; // expected-error {{address taken}} expected-warning {{internal linkage is a C++11 extension}}
+    X3<f_internal> x3d;
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
+    X3<&f_internal> x3d_addr; // expected-error {{address taken}}
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{internal linkage is a C++11 extension}}
+#endif
+
+    int n;
+#if __cplusplus <= 199711L
+    // expected-note@-2 {{non-type template argument refers to object here}}
+#else
+    // expected-note@-4 {{declared here}}
+#endif
+
+    X0<&n> x0_no_linkage;
+#if __cplusplus <= 199711L
+    // expected-error@-2 {{non-type template argument refers to object 'n' that does not have linkage}}
+#else
+    // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}}
+    // expected-note@-5 {{pointer to 'n' is not a constant expression}}
+#endif
 
-    int n; // expected-note {{here}}
-    X0<&n> x0_no_linkage; // expected-error {{non-type template argument refers to object 'n' that does not have linkage}}
     struct Local { static int f() {} }; // expected-note {{here}}
     X1<&Local::f> x1_no_linkage; // expected-error {{non-type template argument refers to function 'f' that does not have linkage}}
     X0<&S::NonStaticMember> x0_non_static; // expected-error {{non-static data member}}
@@ -96,7 +178,17 @@
   int i = 42;
   X0<&i + 2> x0a; // expected-error{{non-type template argument does not refer to any declaration}}
   int* iptr = &i;
-  X0<iptr> x0b; // expected-error{{non-type template argument for template parameter of pointer type 'int *' must have its address taken}}
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{declared here}}
+#endif
+
+  X0<iptr> x0b;
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{non-type template argument for template parameter of pointer type 'int *' must have its address taken}}
+#else
+  // expected-error@-4 {{non-type template argument of type 'int *' is not a constant expression}}
+  // expected-note@-5 {{read of non-constexpr variable 'iptr' is not allowed in a constant expression}}
+#endif
 }
 #endif // CPP11ONLY
 
@@ -108,4 +200,4 @@
 }
 #endif // CPP11ONLY
 
-}
\ No newline at end of file
+}
Index: CXX/stmt.stmt/stmt.dcl/p3.cpp
===================================================================
--- CXX/stmt.stmt/stmt.dcl/p3.cpp
+++ CXX/stmt.stmt/stmt.dcl/p3.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 // PR10034
 struct X {};
@@ -40,8 +42,16 @@
 };
 
 void test_Z() {
-  goto end; // expected-error{{cannot jump from this goto statement to its label}}
-  Z z; // expected-note{{jump bypasses initialization of non-POD variable}}
+  goto end;
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{cannot jump from this goto statement to its label}}
+#endif
+
+  Z z;
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{jump bypasses initialization of non-POD variable}}
+#endif
+
  end:
   return;
 }
Index: CXX/class/class.friend/p2.cpp
===================================================================
--- CXX/class/class.friend/p2.cpp
+++ CXX/class/class.friend/p2.cpp
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct B0;
 
 class A {
   friend class B {}; // expected-error {{cannot define a type in a friend declaration}}
-  friend int; // expected-warning {{non-class friend type 'int' is a C++11 extension}}
-  friend B0; // expected-warning {{specify 'struct' to befriend 'B0'}}
+  friend int;
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{non-class friend type 'int' is a C++11 extension}}
+#endif
+  friend B0;
+#if __cplusplus <= 199711L
+  // expected-warning@-2 {{unelaborated friend declaration is a C++11 extension; specify 'struct' to befriend 'B0'}}
+#endif
   friend class C; // okay
 };
Index: CXX/class/class.friend/p1.cpp
===================================================================
--- CXX/class/class.friend/p1.cpp
+++ CXX/class/class.friend/p1.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct Outer {
   struct Inner {
@@ -41,7 +43,10 @@
   UndeclaredSoFar x; // expected-error {{unknown type name 'UndeclaredSoFar'}}
 
   void a_member();
-  friend void A::a_member(); // expected-error {{friends cannot be members of the declaring class}}
+  friend void A::a_member();
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{friends cannot be members of the declaring class}}
+#endif
   friend void a_member(); // okay (because we ignore class scopes when looking up friends)
   friend class A::AInner; // this is okay as an extension
   friend class AInner; // okay, refers to ::AInner
Index: CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
===================================================================
--- CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
+++ CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++11 %s
 
 // C++98 [basic.lookup.classref]p1:
 //   In a class member access expression (5.2.5), if the . or -> token is
@@ -21,10 +23,16 @@
 
 // From PR 7247
 template<typename T>
-struct set{};  // expected-note{{lookup from the current scope refers here}}
+struct set{};
+#if __cplusplus <= 199711L
+// expected-note@-2 {{lookup from the current scope refers here}}
+#endif
 struct Value {
   template<typename T>
-  void set(T value) {}  // expected-note{{lookup in the object type 'Value' refers here}}
+  void set(T value) {}
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{lookup in the object type 'Value' refers here}}
+#endif
 
   void resolves_to_same() {
     Value v;
@@ -36,7 +44,10 @@
     Value v;
     // The fact that the next line is a warning rather than an error is an
     // extension.
-    v.set<double>(3.2);  // expected-warning{{lookup of 'set' in member access expression is ambiguous; using member of 'Value'}}
+    v.set<double>(3.2);
+#if __cplusplus <= 199711L
+    // expected-warning@-2 {{lookup of 'set' in member access expression is ambiguous; using member of 'Value'}}
+#endif
   }
   {
     int set;  // Non-template.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to