[PATCH] D51021: ABI-Testsuite: Force the old c++11 ABI in mangling/test.xpp
Sunil_Srivastava accepted this revision. Sunil_Srivastava added a comment. This revision is now accepted and ready to land. LGTM Repository: rT test-suite https://reviews.llvm.org/D51021 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46836: Fix some rtti-options tests
Sunil_Srivastava created this revision. Herald added a subscriber: cfe-commits. Certain tests in rtti-options.cpp are not really testing anything because they are testing for the absence of -frtti option to the cc1 process. Since the cc1 process does not take -frtti option, these tests are passing tautologically. The RTTI mode is enabled by default in cc1, and -fno-rtti disables it. Therefore the correct way to check for enabling of RTTI is to check for the absence of -fno-rtti to cc1, and the correct way to check for disabling of RTTI is to check for the presence of -fno-rtti to cc1. This patch fixes those tests. Repository: rC Clang https://reviews.llvm.org/D46836 Files: test/Driver/rtti-options.cpp Index: test/Driver/rtti-options.cpp === --- test/Driver/rtti-options.cpp +++ test/Driver/rtti-options.cpp @@ -5,12 +5,12 @@ // Special cases: -fcxx-exceptions in C code should warn about unused arguments // We should also not have any rtti-related arguments -// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI -check-prefix=CHECK-NO-RTTI %s -// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI -check-prefix=CHECK-NO-RTTI %s +// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s +// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s // Make sure we keep the last -frtti/-fno-rtti argument // RUN: %clang -### -c -fno-rtti -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s -// RUN: %clang -### -c -frtti -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s +// RUN: %clang -### -c -frtti -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI-NOT %s // -fsanitize=vptr // Make sure we only error/warn once, when trying to enable vptr and @@ -43,10 +43,10 @@ // -f{no-,}rtti/default // RUN: %clang -### -c -target x86_64-scei-ps4 -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s -// RUN: %clang -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s +// RUN: %clang -### -c -target x86_64-scei-ps4 -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI-NOT %s +// RUN: %clang -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI-NOT %s // RUN: %clang -### -c -target x86_64-unknown-unknown -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s -// RUN: %clang -### -c -target x86_64-unknown-unknown -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s +// RUN: %clang -### -c -target x86_64-unknown-unknown -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI-NOT %s // RUN: %clang -### -c -target x86_64-unknown-unknown %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s // CHECK-UNUSED: warning: argument unused during compilation: '-fcxx-exceptions' @@ -56,6 +56,5 @@ // CHECK-EXC-ERROR: invalid argument '-fno-rtti' not allowed with '-fexceptions' // CHECK-EXC-ERROR-CXX: invalid argument '-fno-rtti' not allowed with '-fcxx-exceptions' // CHECK-RTTI-NOT: "-fno-rtti" -// CHECK-NO-RTTI-NOT: "-frtti" // CHECK-OK-NOT: {{warning:|error:}} Index: test/Driver/rtti-options.cpp === --- test/Driver/rtti-options.cpp +++ test/Driver/rtti-options.cpp @@ -5,12 +5,12 @@ // Special cases: -fcxx-exceptions in C code should warn about unused arguments // We should also not have any rtti-related arguments -// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI -check-prefix=CHECK-NO-RTTI %s -// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI -check-prefix=CHECK-NO-RTTI %s +// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s +// RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s // Make sure we keep the last -frtti/-fno-rtti argument // RUN: %clang -### -c -fno-rtti -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s -// RUN: %clang -### -c -frtti -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s +// RUN: %clang -### -c -frtti -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI-NOT %s // -fsanitize=vptr // Make sure we only error/warn once, when trying to enable vptr and @@ -43,10 +43,10 @@ // -f{no-,}rtti/default // RU
[PATCH] D46982: Do not enable RTTI with -fexceptions, for PS4
Sunil_Srivastava created this revision. Sunil_Srivastava added a reviewer: filcab. Herald added a subscriber: cfe-commits. NFC for targets other than PS4. This patch is a change in behavior for PS4, in that PS4 will no longer enable RTTI when -fexceptions is specified (RTTI and Exceptions are disabled by default on PS4). RTTI will remain disabled except for types being thrown or caught. Also, '-fexceptions -fno-rtti' (previously prohibited on PS4) is now accepted, as it is for other targets. This patch removes some PS4 specific code, making the code cleaner. Also, in the test file rtti-options.cpp, PS4 tests where the behavior is the same as the generic x86_64-linux are removed, making the test cleaner. Repository: rC Clang https://reviews.llvm.org/D46982 Files: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/ToolChain.h lib/Driver/SanitizerArgs.cpp lib/Driver/ToolChain.cpp lib/Driver/ToolChains/Clang.cpp test/Driver/rtti-options.cpp Index: test/Driver/rtti-options.cpp === --- test/Driver/rtti-options.cpp +++ test/Driver/rtti-options.cpp @@ -1,11 +1,11 @@ // Check that we emit warnings/errors for different combinations of -// exceptions, rtti, and vptr sanitizer flags when targeting the PS4. +// exceptions, rtti, and vptr sanitizer flags for generic (unknown) x86 linux, +// and for PS4 when its behaviour differs from the generic x86-linux. // No warnings/errors should be emitted for unknown, except if combining // the vptr sanitizer with -fno-rtti // Special cases: -fcxx-exceptions in C code should warn about unused arguments // We should also not have any rtti-related arguments -// RUN: %clang -x c -### -target x86_64-scei-ps4 -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s // RUN: %clang -x c -### -target x86_64-unknown-unknown -c -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED -check-prefix=CHECK-RTTI %s // Make sure we keep the last -frtti/-fno-rtti argument @@ -22,39 +22,26 @@ // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -### -c -target x86_64-unknown-linux -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-WARN %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=vptr -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-SAN-ERROR %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fsanitize=undefined -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // Exceptions + no/default rtti -// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR-CXX %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-WARN %s // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // In C++, -fexceptions implies -fcxx-exceptions -// RUN: %clang -x c++ -### -c -target x86_64-scei-ps4 -fexceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-ERROR %s -// RUN: %clang -x c++ -### -c -target x86_64-scei-ps4 -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-EXC-WARN %s // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -x c++ -### -c -target x86_64-unknown-unknown -fexceptions %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // -frtti + exceptions -// RUN: %clang -### -c -target x86_64-scei-ps4 -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // RUN: %clang -### -c -target x86_64-unknown-unknown -fcxx-exceptions -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-OK %s // -f{no-,}rtti/default -// RUN: %clang -### -c -target x86_64-scei-ps4 -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s -// RUN: %clang -### -c -target x86_64-scei-ps4 -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s // RUN: %clang -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s // RUN: %clang -### -c -target x86_64-unknown-unknown -frtti %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s // RUN: %clang -### -c -target x86_64-unknown-unknown -fno-rtti %s 2>&1 | FileCheck -check-prefix=CHECK-NO-RTTI %s // RUN: %clang -### -c -target x86_64-unknown-unknown %s 2>&1 | FileCheck -check-prefix=CHECK-RTTI %s // CHECK-UNUSED: warning: argument unused during compilation: '-fcxx-exceptions' // CHECK-SAN-WARN: implicitly disabling vptr sanitizer because rtti was
[PATCH] D47291: Proposal to make rtti errors more generic.
Sunil_Srivastava created this revision. Herald added a subscriber: cfe-commits. This patch changes the wording of two errors to make them more generic. An attempt to use dynamic_cast while rtti is disabled, curently emits the error: cannot use dynamic_cast with -fno-rtti and a similar one for typeid. This patch proposes to change that to: use of dynamic_cast requires enabling RTTI For targets where the default mode of RTTI is disabled, the current error message is confusing because the user never used the -fno-rtti option. This proposal is motivated by the PS4 compiler, whose default is to have RTTI disabled. However, it is just as clear as the existing diagnostic, and it may be applicable to other llvm compilers having the have the same default as the PS4 compiler. It is also more appropriate in cases where the spelling of the argument (to disable RTTI) is something other than -fno-rtti (for example, /GR- is the switch to disable RTTI for cl). Repository: rC Clang https://reviews.llvm.org/D47291 Files: include/clang/Basic/DiagnosticSemaKinds.td test/SemaCXX/no-rtti.cpp Index: test/SemaCXX/no-rtti.cpp === --- test/SemaCXX/no-rtti.cpp +++ test/SemaCXX/no-rtti.cpp @@ -6,7 +6,7 @@ void f() { - (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}} + (void)typeid(int); // expected-error {{use of typeid requires enabling RTTI}} } namespace { @@ -20,7 +20,7 @@ } bool isa_B(A *a) { - return dynamic_cast(a) != 0; // expected-error {{cannot use dynamic_cast with -fno-rtti}} + return dynamic_cast(a) != 0; // expected-error {{use of dynamic_cast requires enabling RTTI}} } void* getMostDerived(A* a) { Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -6724,9 +6724,9 @@ "no %select{struct|interface|union|class|enum}0 named %1 in %2">; def err_no_typeid_with_fno_rtti : Error< - "cannot use typeid with -fno-rtti">; + "use of typeid requires enabling RTTI">; def err_no_dynamic_cast_with_fno_rtti : Error< - "cannot use dynamic_cast with -fno-rtti">; + "use of dynamic_cast requires enabling RTTI">; def err_cannot_form_pointer_to_member_of_reference_type : Error< "cannot form a pointer-to-member to member %0 of reference type %1">; Index: test/SemaCXX/no-rtti.cpp === --- test/SemaCXX/no-rtti.cpp +++ test/SemaCXX/no-rtti.cpp @@ -6,7 +6,7 @@ void f() { - (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}} + (void)typeid(int); // expected-error {{use of typeid requires enabling RTTI}} } namespace { @@ -20,7 +20,7 @@ } bool isa_B(A *a) { - return dynamic_cast(a) != 0; // expected-error {{cannot use dynamic_cast with -fno-rtti}} + return dynamic_cast(a) != 0; // expected-error {{use of dynamic_cast requires enabling RTTI}} } void* getMostDerived(A* a) { Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -6724,9 +6724,9 @@ "no %select{struct|interface|union|class|enum}0 named %1 in %2">; def err_no_typeid_with_fno_rtti : Error< - "cannot use typeid with -fno-rtti">; + "use of typeid requires enabling RTTI">; def err_no_dynamic_cast_with_fno_rtti : Error< - "cannot use dynamic_cast with -fno-rtti">; + "use of dynamic_cast requires enabling RTTI">; def err_cannot_form_pointer_to_member_of_reference_type : Error< "cannot form a pointer-to-member to member %0 of reference type %1">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47291: Proposal to make rtti errors more generic.
Sunil_Srivastava added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6729 def err_no_dynamic_cast_with_fno_rtti : Error< - "cannot use dynamic_cast with -fno-rtti">; + "use of dynamic_cast requires enabling RTTI">; probinson wrote: > filcab wrote: > > I'd prefer to have the way to enable RTTI mentioned in the message. Could > > we have something like `ToolChain::getRTTIMode()` and have a "RTTI was > > on/of" or "RTTI defaulted to on/off"? That way we'd be able to have a > > message similar to the current one (mentioning "you passed -fno-rtti") on > > platforms that default to RTTI=on, and have your updated message (possibly > > with a mention of "use -frtti") on platforms that default to RTTI=off. > > > > (This is a minor usability comment about this patch, I don't consider it a > > blocker or anything) > If the options are spelled differently for clang-cl and we had a way to > retrieve the appropriate spellings, providing the option to use in the > diagnostic does seem like a nice touch. The idea of suggestion as to how-to-turn-on-rtti is appealing, but it is not trivial. First, clang-cl does not give this warning at all, so the issue is moot for clang-cl. For unix-line command-line, if the default RTTI mode in ENABLED (the unknown-linux) then this warning appears only if the user gives -fno-rtti options, so again we do not need to say anything more. The only cases left are compilers a where the default RTTI mode is DISABLED. Here an addendum like '[-frtti]' may make sense. AFAIK, PS4 is the only compiler with this default, but there may be other such private compilers. So should we append '[-frtti]' if Target.getTriple().isPS4() is true? Repository: rC Clang https://reviews.llvm.org/D47291 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47291: Proposal to make rtti errors more generic.
Sunil_Srivastava added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:6729 def err_no_dynamic_cast_with_fno_rtti : Error< - "cannot use dynamic_cast with -fno-rtti">; + "use of dynamic_cast requires enabling RTTI">; wristow wrote: > probinson wrote: > > wristow wrote: > > > Sunil_Srivastava wrote: > > > > probinson wrote: > > > > > filcab wrote: > > > > > > I'd prefer to have the way to enable RTTI mentioned in the message. > > > > > > Could we have something like `ToolChain::getRTTIMode()` and have a > > > > > > "RTTI was on/of" or "RTTI defaulted to on/off"? That way we'd be > > > > > > able to have a message similar to the current one (mentioning "you > > > > > > passed -fno-rtti") on platforms that default to RTTI=on, and have > > > > > > your updated message (possibly with a mention of "use -frtti") on > > > > > > platforms that default to RTTI=off. > > > > > > > > > > > > (This is a minor usability comment about this patch, I don't > > > > > > consider it a blocker or anything) > > > > > If the options are spelled differently for clang-cl and we had a way > > > > > to retrieve the appropriate spellings, providing the option to use in > > > > > the diagnostic does seem like a nice touch. > > > > The idea of suggestion as to how-to-turn-on-rtti is appealing, but it > > > > is not trivial. > > > > > > > > First, clang-cl does not give this warning at all, so the issue is moot > > > > for clang-cl. > > > > > > > > For unix-line command-line, if the default RTTI mode in ENABLED (the > > > > unknown-linux) > > > > then this warning appears only if the user gives -fno-rtti options, so > > > > again we do > > > > not need to say anything more. > > > > > > > > The only cases left are compilers a where the default RTTI mode is > > > > DISABLED. > > > > Here an addendum like '[-frtti]' may make sense. AFAIK, PS4 is the only > > > > compiler > > > > with this default, but there may be other such private compilers. > > > > > > > > So should we append '[-frtti]' if Target.getTriple().isPS4() is true? > > > > So should we append '[-frtti]' if Target.getTriple().isPS4() is true? > > > > > > Personally, I'd be OK with producing a suggestion of how to enable RTTI > > > based on the PS4 triple. But I'd also be OK with not enhancing this > > > diagnostic to suggest how to turn on RTTI (that is, going with the patch > > > as originally proposed here). > > > > > > If clang-cl produced a warning when a dynamic_cast or typeid construct > > > was encountered in `/GR-` mode, then I'd feel it's worth complicating the > > > code to provide a target-sensitive way for advising the user how to turn > > > RTTI on. But clang-cl doesn't produce a warning in that case, so the > > > effort to add the framework for producing a target-sensitive warning > > > doesn't seem worth it to me. > > > > > > Improving clang-cl to produce a diagnostic in this `/GR-` situation seems > > > like a good idea, but separate from this proposed patch. If that work > > > gets done at some point, then it would be natural to revisit this > > > diagnostic at that time. > > If clang-cl is not a consideration, then I think the easiest and clearest > > way to do this is simply to say `requires -frtti` without hair-splitting > > which targets default which way. > Saying `requires -frtti` makes good sense to me. Done https://reviews.llvm.org/D47291 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D47291: Proposal to make rtti errors more generic.
Sunil_Srivastava updated this revision to Diff 150038. Sunil_Srivastava added a comment. Changed as per Paul's suggestion. https://reviews.llvm.org/D47291 Files: include/clang/Basic/DiagnosticSemaKinds.td test/SemaCXX/no-rtti.cpp Index: test/SemaCXX/no-rtti.cpp === --- test/SemaCXX/no-rtti.cpp +++ test/SemaCXX/no-rtti.cpp @@ -6,7 +6,7 @@ void f() { - (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}} + (void)typeid(int); // expected-error {{use of typeid requires -frtti}} } namespace { @@ -20,7 +20,7 @@ } bool isa_B(A *a) { - return dynamic_cast(a) != 0; // expected-error {{cannot use dynamic_cast with -fno-rtti}} + return dynamic_cast(a) != 0; // expected-error {{use of dynamic_cast requires -frtti}} } void* getMostDerived(A* a) { Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -6607,9 +6607,9 @@ "no %select{struct|interface|union|class|enum}0 named %1 in %2">; def err_no_typeid_with_fno_rtti : Error< - "cannot use typeid with -fno-rtti">; + "use of typeid requires -frtti">; def err_no_dynamic_cast_with_fno_rtti : Error< - "cannot use dynamic_cast with -fno-rtti">; + "use of dynamic_cast requires -frtti">; def err_cannot_form_pointer_to_member_of_reference_type : Error< "cannot form a pointer-to-member to member %0 of reference type %1">; Index: test/SemaCXX/no-rtti.cpp === --- test/SemaCXX/no-rtti.cpp +++ test/SemaCXX/no-rtti.cpp @@ -6,7 +6,7 @@ void f() { - (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}} + (void)typeid(int); // expected-error {{use of typeid requires -frtti}} } namespace { @@ -20,7 +20,7 @@ } bool isa_B(A *a) { - return dynamic_cast(a) != 0; // expected-error {{cannot use dynamic_cast with -fno-rtti}} + return dynamic_cast(a) != 0; // expected-error {{use of dynamic_cast requires -frtti}} } void* getMostDerived(A* a) { Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -6607,9 +6607,9 @@ "no %select{struct|interface|union|class|enum}0 named %1 in %2">; def err_no_typeid_with_fno_rtti : Error< - "cannot use typeid with -fno-rtti">; + "use of typeid requires -frtti">; def err_no_dynamic_cast_with_fno_rtti : Error< - "cannot use dynamic_cast with -fno-rtti">; + "use of dynamic_cast requires -frtti">; def err_cannot_form_pointer_to_member_of_reference_type : Error< "cannot form a pointer-to-member to member %0 of reference type %1">; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64780: Disallow most calling convention attributes on PS4.
Sunil_Srivastava created this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. We wish to disable most calling convention attributes for PS4, allowing just cdecl (and the equivalent sysv_abi on PS4), which are default. Repository: rC Clang https://reviews.llvm.org/D64780 Files: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/TargetInfo.h lib/Basic/Targets/X86.h lib/Sema/SemaDeclAttr.cpp test/Sema/no_callconv.cpp unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp Index: unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp === --- unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp +++ unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp @@ -86,6 +86,8 @@ } TEST(RecursiveASTVisitor, VisitsAttributedLambdaExpr) { + if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).isPS4()) +return; // PS4 does not support fastcall. LambdaExprVisitor Visitor; Visitor.ExpectMatch("", 1, 12); EXPECT_TRUE(Visitor.runOver( Index: test/Sema/no_callconv.cpp === --- test/Sema/no_callconv.cpp +++ test/Sema/no_callconv.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -DPS4 -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fsyntax-only -verify + +#ifdef PS4 + +// PS4 does not support these. +void __vectorcall func_vc() {} // expected-error {{'__vectorcall' calling convention not supported for this target}} +void __regcall func_rc() {} // expected-error {{'__regcall' calling convention not supported for this target}} +void __attribute__((vectorcall)) funcA() {} // expected-error {{'vectorcall' calling convention not supported for this target}} +void __attribute__((regcall)) funcB() {} // expected-error {{'regcall' calling convention not supported for this target}} +void __attribute__((ms_abi)) funcH() {} // expected-error {{'ms_abi' calling convention not supported for this target}} +void __attribute__((intel_ocl_bicc)) funcJ() {} // expected-error {{'intel_ocl_bicc' calling convention not supported for this target}} +void __attribute__((swiftcall)) funcK() {} // expected-error {{'swiftcall' calling convention not supported for this target}} +void __attribute__((pascal)) funcG() {} // expected-error {{'pascal' calling convention not supported for this target}} +void __attribute__((preserve_most)) funcL() {} // expected-error {{'preserve_most' calling convention not supported for this target}} +void __attribute__((preserve_all)) funcM() {} // expected-error {{'preserve_all' calling convention not supported for this target}} +void __attribute__((stdcall)) funcD() {} // expected-error {{'stdcall' calling convention not supported for this target}} +void __attribute__((fastcall)) funcE() {} // expected-error {{'fastcall' calling convention not supported for this target}} +void __attribute__((thiscall)) funcF() {} // expected-error {{'thiscall' calling convention not supported for this target}} +#else + +void __vectorcall func_vc() {} +void __regcall func_rc() {} +void __attribute__((vectorcall)) funcA() {} +void __attribute__((regcall)) funcB() {} +void __attribute__((ms_abi)) funcH() {} +void __attribute__((intel_ocl_bicc)) funcJ() {} +void __attribute__((swiftcall)) funcK() {} +void __attribute__((preserve_most)) funcL() {} +void __attribute__((preserve_all)) funcM() {} + +// Same function with different calling conventions. Error with a note pointing to the last decl. +void __attribute__((preserve_all)) funcR(); // expected-note {{previous declaration is here}} +void __attribute__((preserve_most)) funcR(); // expected-error {{function declared 'preserve_most' here was previously declared 'preserve_all'}} + +void __attribute__((pascal)) funcG() {} // expected-warning {{'pascal' calling convention ignored for this target}} + +void __attribute__((stdcall)) funcD() {} // expected-warning {{'stdcall' calling convention ignored for this target}} +void __attribute__((fastcall)) funcE() {} // expected-warning {{'fastcall' calling convention ignored for this target}} +void __attribute__((thiscall)) funcF() {} // expected-warning {{'thiscall' calling convention ignored for this target}} +#endif + +void __attribute__((sysv_abi)) funcI() {} +void __attribute__((cdecl)) funcC() {} Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -4668,6 +4668,11 @@ CC = CC_C; break; + case TargetInfo::CCCR_Error: +Diag(Attrs.getLoc(), diag::error_cconv_unsupported) +<< Attrs << (int)CallingConventionIgnoredReason::ForThisTarget; +break; + case TargetInfo::CCCR_Warning: { Diag(Attrs.getLoc(), diag::warn_cconv_ignored) << Attrs << (int)CallingConventionIgnoredReason::ForThisTarget; Index: lib/Basic/Targets/X86.h =
[PATCH] D64780: Disallow most calling convention attributes on PS4.
Sunil_Srivastava removed reviewers: wristow, rnk, rjmccall. Sunil_Srivastava marked an inline comment as done. Sunil_Srivastava added inline comments. Comment at: include/clang/Basic/DiagnosticSemaKinds.td:2961 +def error_cconv_unsupported : Error< + "%0 calling convention not supported %select{" + // Use CallingConventionIgnoredReason Enum to specify these. rnk wrote: > This duplication merely to say "not supported" instead of "ignored" seems > unfortunate. We could reasonable change "ignored" to "unsupported" and then > you could use the warn_cconv_ignored.Text accessor to share the text. Good point. I will make a pre-commit of just changing the wording (and renaming) of warn_cconv_ignored. Then the warn_conv_unsupported.Text will be used in the actual change. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64780/new/ https://reviews.llvm.org/D64780 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64780: Disallow most calling convention attributes on PS4.
Sunil_Srivastava marked an inline comment as done. Sunil_Srivastava added inline comments. Comment at: test/Sema/no_callconv.cpp:1 +// RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -DPS4 -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fsyntax-only -verify aaron.ballman wrote: > Does this really need an svn:executable property on the file? I am not sure where that comes from. I did an 'svn add' and 'svn diff'. Regardless, it will be a new test file with normal lines. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64780/new/ https://reviews.llvm.org/D64780 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64780: Disallow most calling convention attributes on PS4.
Sunil_Srivastava added a comment. Pre-commit to change the wording and ID of warn_cconv_ignore has gone in in r366368. I will be shortly updating this review to account for that, and for other points raised here. Repository: rC Clang CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64780/new/ https://reviews.llvm.org/D64780 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D64780: Disallow most calling convention attributes on PS4.
Sunil_Srivastava updated this revision to Diff 210674. Sunil_Srivastava added a comment. - Adapted suggestion from Ried. - Cleaned up line ending and properties of the test case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64780/new/ https://reviews.llvm.org/D64780 Files: include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/TargetInfo.h lib/Basic/Targets/OSTargets.h lib/Sema/SemaDeclAttr.cpp test/Sema/no_callconv.cpp unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp Index: unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp === --- unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp +++ unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp @@ -86,6 +86,8 @@ } TEST(RecursiveASTVisitor, VisitsAttributedLambdaExpr) { + if (llvm::Triple(llvm::sys::getDefaultTargetTriple()).isPS4()) +return; // PS4 does not support fastcall. LambdaExprVisitor Visitor; Visitor.ExpectMatch("", 1, 12); EXPECT_TRUE(Visitor.runOver( Index: test/Sema/no_callconv.cpp === --- test/Sema/no_callconv.cpp +++ test/Sema/no_callconv.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 %s -triple x86_64-scei-ps4 -DPS4 -fsyntax-only -verify +// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fsyntax-only -verify + +#ifdef PS4 + +// PS4 does not support these. +void __vectorcall func_vc() {} // expected-error {{'__vectorcall' calling convention is not supported for this target}} +void __regcall func_rc() {} // expected-error {{'__regcall' calling convention is not supported for this target}} +void __attribute__((vectorcall)) funcA() {} // expected-error {{'vectorcall' calling convention is not supported for this target}} +void __attribute__((regcall)) funcB() {} // expected-error {{'regcall' calling convention is not supported for this target}} +void __attribute__((ms_abi)) funcH() {} // expected-error {{'ms_abi' calling convention is not supported for this target}} +void __attribute__((intel_ocl_bicc)) funcJ() {} // expected-error {{'intel_ocl_bicc' calling convention is not supported for this target}} +void __attribute__((swiftcall)) funcK() {} // expected-error {{'swiftcall' calling convention is not supported for this target}} +void __attribute__((pascal)) funcG() {} // expected-error {{'pascal' calling convention is not supported for this target}} +void __attribute__((preserve_most)) funcL() {} // expected-error {{'preserve_most' calling convention is not supported for this target}} +void __attribute__((preserve_all)) funcM() {} // expected-error {{'preserve_all' calling convention is not supported for this target}} +void __attribute__((stdcall)) funcD() {} // expected-error {{'stdcall' calling convention is not supported for this target}} +void __attribute__((fastcall)) funcE() {} // expected-error {{'fastcall' calling convention is not supported for this target}} +void __attribute__((thiscall)) funcF() {} // expected-error {{'thiscall' calling convention is not supported for this target}} +#else + +void __vectorcall func_vc() {} +void __regcall func_rc() {} +void __attribute__((vectorcall)) funcA() {} +void __attribute__((regcall)) funcB() {} +void __attribute__((ms_abi)) funcH() {} +void __attribute__((intel_ocl_bicc)) funcJ() {} +void __attribute__((swiftcall)) funcK() {} +void __attribute__((preserve_most)) funcL() {} +void __attribute__((preserve_all)) funcM() {} + +// Same function with different calling conventions. Error with a note pointing to the last decl. +void __attribute__((preserve_all)) funcR(); // expected-note {{previous declaration is here}} +void __attribute__((preserve_most)) funcR(); // expected-error {{function declared 'preserve_most' here was previously declared 'preserve_all'}} + +void __attribute__((pascal)) funcG() {} // expected-warning {{'pascal' calling convention is not supported for this target}} + +void __attribute__((stdcall)) funcD() {} // expected-warning {{'stdcall' calling convention is not supported for this target}} +void __attribute__((fastcall)) funcE() {} // expected-warning {{'fastcall' calling convention is not supported for this target}} +void __attribute__((thiscall)) funcF() {} // expected-warning {{'thiscall' calling convention is not supported for this target}} +#endif + +void __attribute__((sysv_abi)) funcI() {} +void __attribute__((cdecl)) funcC() {} Index: lib/Sema/SemaDeclAttr.cpp === --- lib/Sema/SemaDeclAttr.cpp +++ lib/Sema/SemaDeclAttr.cpp @@ -4668,6 +4668,11 @@ CC = CC_C; break; + case TargetInfo::CCCR_Error: +Diag(Attrs.getLoc(), diag::error_cconv_unsupported) +<< Attrs << (int)CallingConventionIgnoredReason::ForThisTarget; +break; + case TargetInfo::CCCR_Warning: { Diag(Attrs.getLoc(), diag::warn_cconv_unsupported) << Attrs << (int)CallingConventionIgnoredReason::ForThisTa
[PATCH] D64780: Disallow most calling convention attributes on PS4.
Sunil_Srivastava marked an inline comment as done. Sunil_Srivastava added inline comments. Comment at: lib/Basic/Targets/OSTargets.h:564 } + TargetInfo::CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { +return (CC == CC_C) ? TargetInfo::CCCR_OK : TargetInfo::CCCR_Error; aaron.ballman wrote: > Line length seems a bit long for coding style requirements. Ooops. You are right. Will split according to clang-format. Would you want me to update the review? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D64780/new/ https://reviews.llvm.org/D64780 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129404: Change default C dialect for PS5 to gnu17/gnu18.
Sunil_Srivastava created this revision. Sunil_Srivastava added reviewers: probinson, wristow. Herald added a project: All. Sunil_Srivastava requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D129404 Files: clang/lib/Basic/LangStandards.cpp clang/test/Preprocessor/init.c Index: clang/test/Preprocessor/init.c === --- clang/test/Preprocessor/init.c +++ clang/test/Preprocessor/init.c @@ -1342,7 +1342,8 @@ // PS4:#define __SSE2__ 1 // PS4:#define __SSE_MATH__ 1 // PS4:#define __SSE__ 1 -// PS4:#define __STDC_VERSION__ 199901L +// PS4ONLY:#define __STDC_VERSION__ 199901L +// PS5ONLY:#define __STDC_VERSION__ 201710L // PS4:#define __UINTMAX_TYPE__ long unsigned int // PS4:#define __USER_LABEL_PREFIX__ // PS4:#define __WCHAR_MAX__ 65535 Index: clang/lib/Basic/LangStandards.cpp === --- clang/lib/Basic/LangStandards.cpp +++ clang/lib/Basic/LangStandards.cpp @@ -61,8 +61,8 @@ if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified) return CLANG_DEFAULT_STD_C; -// The PS4 and PS5 use C99 as the default C standard. -if (T.isPS()) +// The PS4 uses C99 as the default C standard. +if (T.isPS4()) return LangStandard::lang_gnu99; return LangStandard::lang_gnu17; case Language::ObjC: Index: clang/test/Preprocessor/init.c === --- clang/test/Preprocessor/init.c +++ clang/test/Preprocessor/init.c @@ -1342,7 +1342,8 @@ // PS4:#define __SSE2__ 1 // PS4:#define __SSE_MATH__ 1 // PS4:#define __SSE__ 1 -// PS4:#define __STDC_VERSION__ 199901L +// PS4ONLY:#define __STDC_VERSION__ 199901L +// PS5ONLY:#define __STDC_VERSION__ 201710L // PS4:#define __UINTMAX_TYPE__ long unsigned int // PS4:#define __USER_LABEL_PREFIX__ // PS4:#define __WCHAR_MAX__ 65535 Index: clang/lib/Basic/LangStandards.cpp === --- clang/lib/Basic/LangStandards.cpp +++ clang/lib/Basic/LangStandards.cpp @@ -61,8 +61,8 @@ if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified) return CLANG_DEFAULT_STD_C; -// The PS4 and PS5 use C99 as the default C standard. -if (T.isPS()) +// The PS4 uses C99 as the default C standard. +if (T.isPS4()) return LangStandard::lang_gnu99; return LangStandard::lang_gnu17; case Language::ObjC: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D129404: Change default C dialect for PS5 to gnu17/gnu18.
This revision was automatically updated to reflect the committed changes. Closed by commit rGa844378b2bc2: Change default C dialect for PS5 to gnu17/gnu18. (authored by Sunil_Srivastava). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129404/new/ https://reviews.llvm.org/D129404 Files: clang/lib/Basic/LangStandards.cpp clang/test/Preprocessor/init.c Index: clang/test/Preprocessor/init.c === --- clang/test/Preprocessor/init.c +++ clang/test/Preprocessor/init.c @@ -1342,7 +1342,8 @@ // PS4:#define __SSE2__ 1 // PS4:#define __SSE_MATH__ 1 // PS4:#define __SSE__ 1 -// PS4:#define __STDC_VERSION__ 199901L +// PS4ONLY:#define __STDC_VERSION__ 199901L +// PS5ONLY:#define __STDC_VERSION__ 201710L // PS4:#define __UINTMAX_TYPE__ long unsigned int // PS4:#define __USER_LABEL_PREFIX__ // PS4:#define __WCHAR_MAX__ 65535 Index: clang/lib/Basic/LangStandards.cpp === --- clang/lib/Basic/LangStandards.cpp +++ clang/lib/Basic/LangStandards.cpp @@ -61,8 +61,8 @@ if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified) return CLANG_DEFAULT_STD_C; -// The PS4 and PS5 use C99 as the default C standard. -if (T.isPS()) +// The PS4 uses C99 as the default C standard. +if (T.isPS4()) return LangStandard::lang_gnu99; return LangStandard::lang_gnu17; case Language::ObjC: Index: clang/test/Preprocessor/init.c === --- clang/test/Preprocessor/init.c +++ clang/test/Preprocessor/init.c @@ -1342,7 +1342,8 @@ // PS4:#define __SSE2__ 1 // PS4:#define __SSE_MATH__ 1 // PS4:#define __SSE__ 1 -// PS4:#define __STDC_VERSION__ 199901L +// PS4ONLY:#define __STDC_VERSION__ 199901L +// PS5ONLY:#define __STDC_VERSION__ 201710L // PS4:#define __UINTMAX_TYPE__ long unsigned int // PS4:#define __USER_LABEL_PREFIX__ // PS4:#define __WCHAR_MAX__ 65535 Index: clang/lib/Basic/LangStandards.cpp === --- clang/lib/Basic/LangStandards.cpp +++ clang/lib/Basic/LangStandards.cpp @@ -61,8 +61,8 @@ if (CLANG_DEFAULT_STD_C != LangStandard::lang_unspecified) return CLANG_DEFAULT_STD_C; -// The PS4 and PS5 use C99 as the default C standard. -if (T.isPS()) +// The PS4 uses C99 as the default C standard. +if (T.isPS4()) return LangStandard::lang_gnu99; return LangStandard::lang_gnu17; case Language::ObjC: ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D86649: Fix for assertion failure on PR46865
Sunil_Srivastava created this revision. Sunil_Srivastava added reviewers: rsmith, erichkeane. Herald added a project: clang. Herald added a subscriber: cfe-commits. Sunil_Srivastava requested review of this revision. This is a proposed fix for the crash of PR46865. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D86649 Files: clang/lib/AST/ExprConstant.cpp clang/test/AST/pr46865.cpp Index: clang/test/AST/pr46865.cpp === --- /dev/null +++ clang/test/AST/pr46865.cpp @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -fsyntax-only %s +typedef unsigned long size_t; + +namespace std { +template struct add_const { typedef const _Ty type; }; + +template class tuple {A a; B b; }; +template struct tuple_size; +template struct tuple_size {static constexpr size_t value = 2;}; // hardcoded 2 + +template struct tuple_element; +template struct tuple_element<0, tuple<_This, _that> > { typedef _This type; }; +template struct tuple_element<1, tuple<_This, _that> > { typedef _that type; }; + +template struct tuple_element<_Index, const _Tuple> { + typedef tuple_element<_Index, _Tuple> _Mybase; + typedef typename add_const::type type; +}; + +template inline constexpr const typename tuple_element<_Index, tuple >::type& + get(const tuple& _Tuple) noexcept {} + +template inline constexpr const typename tuple_element<0, tuple >::type& + get(const tuple& _Tuple) noexcept { return _Tuple.a; } +template inline constexpr const typename tuple_element<1, tuple >::type& + get(const tuple& _Tuple) noexcept { return _Tuple.b; } +} +std::tuple inline __attribute__((always_inline)) get_sc(unsigned v) {} + +template class bbb { + unsigned u; + inline __attribute__((always_inline)) void cebb(); +}; + +template void bbb::cebb() +{ + unsigned p; + auto const t = u; + auto const [s, c] = get_sc(t); + p = s; +} + Index: clang/lib/AST/ExprConstant.cpp === --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -3095,7 +3095,7 @@ // constant-folding cases, where the variable is not actually of a suitable // type for use in a constant expression (otherwise the DeclRefExpr would // have been value-dependent too), so diagnose that. -assert(!VD->mightBeUsableInConstantExpressions(Info.Ctx)); +assert(!VD->isUsableInConstantExpressions(Info.Ctx)); if (!Info.checkingPotentialConstantExpression()) { Info.FFDiag(E, Info.getLangOpts().CPlusPlus11 ? diag::note_constexpr_ltor_non_constexpr Index: clang/test/AST/pr46865.cpp === --- /dev/null +++ clang/test/AST/pr46865.cpp @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -fsyntax-only %s +typedef unsigned long size_t; + +namespace std { +template struct add_const { typedef const _Ty type; }; + +template class tuple {A a; B b; }; +template struct tuple_size; +template struct tuple_size {static constexpr size_t value = 2;}; // hardcoded 2 + +template struct tuple_element; +template struct tuple_element<0, tuple<_This, _that> > { typedef _This type; }; +template struct tuple_element<1, tuple<_This, _that> > { typedef _that type; }; + +template struct tuple_element<_Index, const _Tuple> { + typedef tuple_element<_Index, _Tuple> _Mybase; + typedef typename add_const::type type; +}; + +template inline constexpr const typename tuple_element<_Index, tuple >::type& + get(const tuple& _Tuple) noexcept {} + +template inline constexpr const typename tuple_element<0, tuple >::type& + get(const tuple& _Tuple) noexcept { return _Tuple.a; } +template inline constexpr const typename tuple_element<1, tuple >::type& + get(const tuple& _Tuple) noexcept { return _Tuple.b; } +} +std::tuple inline __attribute__((always_inline)) get_sc(unsigned v) {} + +template class bbb { + unsigned u; + inline __attribute__((always_inline)) void cebb(); +}; + +template void bbb::cebb() +{ + unsigned p; + auto const t = u; + auto const [s, c] = get_sc(t); + p = s; +} + Index: clang/lib/AST/ExprConstant.cpp === --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -3095,7 +3095,7 @@ // constant-folding cases, where the variable is not actually of a suitable // type for use in a constant expression (otherwise the DeclRefExpr would // have been value-dependent too), so diagnose that. -assert(!VD->mightBeUsableInConstantExpressions(Info.Ctx)); +assert(!VD->isUsableInConstantExpressions(Info.Ctx)); if (!Info.checkingPotentialConstantExpression()) { Info.FFDiag(E, Info.getLangOpts().CPlusPlus11 ? diag::note_constexpr_ltor_non_constexpr ___ cfe-commits mailing list cfe-commits@lists.llvm.o
[PATCH] D155998: Set default C++ level for Playstation to C++17.
Sunil_Srivastava created this revision. Herald added a project: All. Sunil_Srivastava requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D155998 Files: clang/lib/Basic/LangStandards.cpp clang/test/Preprocessor/lang-std-sie.cpp Index: clang/test/Preprocessor/lang-std-sie.cpp === --- clang/test/Preprocessor/lang-std-sie.cpp +++ clang/test/Preprocessor/lang-std-sie.cpp @@ -1,6 +1,6 @@ -/// Test that PS4/PS5 defaults to gnu++14. +/// Test that PS4/PS5 defaults to gnu++17. -// RUN: %clang_cc1 -dM -E -triple x86_64-scei-ps4 %s | FileCheck --check-prefix=CXX14 %s -// RUN: %clang_cc1 -dM -E -triple x86_64-sie-ps5 %s | FileCheck --check-prefix=CXX14 %s +// RUN: %clang_cc1 -dM -E -triple x86_64-scei-ps4 %s | FileCheck --check-prefix=CXX17 %s +// RUN: %clang_cc1 -dM -E -triple x86_64-sie-ps5 %s | FileCheck --check-prefix=CXX17 %s -// CXX14: #define __cplusplus 201402L +// CXX17: #define __cplusplus 201703L Index: clang/lib/Basic/LangStandards.cpp === --- clang/lib/Basic/LangStandards.cpp +++ clang/lib/Basic/LangStandards.cpp @@ -66,8 +66,6 @@ case Language::ObjCXX: case Language::CUDA: case Language::HIP: -if (T.isPS()) - return LangStandard::lang_gnucxx14; return LangStandard::lang_gnucxx17; case Language::RenderScript: return LangStandard::lang_c99; Index: clang/test/Preprocessor/lang-std-sie.cpp === --- clang/test/Preprocessor/lang-std-sie.cpp +++ clang/test/Preprocessor/lang-std-sie.cpp @@ -1,6 +1,6 @@ -/// Test that PS4/PS5 defaults to gnu++14. +/// Test that PS4/PS5 defaults to gnu++17. -// RUN: %clang_cc1 -dM -E -triple x86_64-scei-ps4 %s | FileCheck --check-prefix=CXX14 %s -// RUN: %clang_cc1 -dM -E -triple x86_64-sie-ps5 %s | FileCheck --check-prefix=CXX14 %s +// RUN: %clang_cc1 -dM -E -triple x86_64-scei-ps4 %s | FileCheck --check-prefix=CXX17 %s +// RUN: %clang_cc1 -dM -E -triple x86_64-sie-ps5 %s | FileCheck --check-prefix=CXX17 %s -// CXX14: #define __cplusplus 201402L +// CXX17: #define __cplusplus 201703L Index: clang/lib/Basic/LangStandards.cpp === --- clang/lib/Basic/LangStandards.cpp +++ clang/lib/Basic/LangStandards.cpp @@ -66,8 +66,6 @@ case Language::ObjCXX: case Language::CUDA: case Language::HIP: -if (T.isPS()) - return LangStandard::lang_gnucxx14; return LangStandard::lang_gnucxx17; case Language::RenderScript: return LangStandard::lang_c99; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D155998: Set default C++ level for PlayStation(r) to C++17.
Sunil_Srivastava updated this revision to Diff 543088. Sunil_Srivastava added a comment. Deleted Sie specific test, now that the behavior is same as the default. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155998/new/ https://reviews.llvm.org/D155998 Files: clang/lib/Basic/LangStandards.cpp clang/test/Preprocessor/lang-std-sie.cpp Index: clang/test/Preprocessor/lang-std-sie.cpp === --- clang/test/Preprocessor/lang-std-sie.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/// Test that PS4/PS5 defaults to gnu++14. - -// RUN: %clang_cc1 -dM -E -triple x86_64-scei-ps4 %s | FileCheck --check-prefix=CXX14 %s -// RUN: %clang_cc1 -dM -E -triple x86_64-sie-ps5 %s | FileCheck --check-prefix=CXX14 %s - -// CXX14: #define __cplusplus 201402L Index: clang/lib/Basic/LangStandards.cpp === --- clang/lib/Basic/LangStandards.cpp +++ clang/lib/Basic/LangStandards.cpp @@ -66,8 +66,6 @@ case Language::ObjCXX: case Language::CUDA: case Language::HIP: -if (T.isPS()) - return LangStandard::lang_gnucxx14; return LangStandard::lang_gnucxx17; case Language::RenderScript: return LangStandard::lang_c99; Index: clang/test/Preprocessor/lang-std-sie.cpp === --- clang/test/Preprocessor/lang-std-sie.cpp +++ /dev/null @@ -1,6 +0,0 @@ -/// Test that PS4/PS5 defaults to gnu++14. - -// RUN: %clang_cc1 -dM -E -triple x86_64-scei-ps4 %s | FileCheck --check-prefix=CXX14 %s -// RUN: %clang_cc1 -dM -E -triple x86_64-sie-ps5 %s | FileCheck --check-prefix=CXX14 %s - -// CXX14: #define __cplusplus 201402L Index: clang/lib/Basic/LangStandards.cpp === --- clang/lib/Basic/LangStandards.cpp +++ clang/lib/Basic/LangStandards.cpp @@ -66,8 +66,6 @@ case Language::ObjCXX: case Language::CUDA: case Language::HIP: -if (T.isPS()) - return LangStandard::lang_gnucxx14; return LangStandard::lang_gnucxx17; case Language::RenderScript: return LangStandard::lang_c99; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22057: Prevent devirtualization of calls to un-instantiated functions.
Sunil_Srivastava added a comment. Ping https://reviews.llvm.org/D22057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D22057: Prevent devirtualization of calls to un-instantiated functions.
Sunil_Srivastava added a comment. A friendly ping. https://reviews.llvm.org/D22057 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D94438: Fis for Assertion failure on dependent expression.
Sunil_Srivastava created this revision. Sunil_Srivastava added reviewers: jstenglein, erichkeane. Sunil_Srivastava requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits. The check for the value passed to __buildtin_return_address needs to be guarded by check for the Dependent context, or else it runs into an assertion failure in the test case given below. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D94438 Files: clang/lib/Sema/SemaChecking.cpp clang/test/Sema/builtin-returnaddress.c Index: clang/test/Sema/builtin-returnaddress.c === --- clang/test/Sema/builtin-returnaddress.c +++ clang/test/Sema/builtin-returnaddress.c @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s // RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s +// RUN: %clang_cc1 -x c++ -fsyntax-only -Wframe-address -verify %s +// RUN: %clang_cc1 -x c++ -fsyntax-only -Wmost -verify %s void* a(unsigned x) { return __builtin_return_address(0); @@ -17,3 +19,14 @@ return __builtin_frame_address(1); // expected-warning{{calling '__builtin_frame_address' with a nonzero argument is unsafe}} } +#ifdef __cplusplus +template void *RA() +{ + return __builtin_return_address(N); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}} +} + +void *foo() +{ + return RA<2>(); // expected-note{{in instantiation of function template specialization 'RA<2>' requested here}} +} +#endif Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -1942,7 +1942,8 @@ // -Wframe-address warning if non-zero passed to builtin // return/frame address. Expr::EvalResult Result; -if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) && +if (!TheCall->getArg(0)->isValueDependent() && +TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) && Result.Val.getInt() != 0) Diag(TheCall->getBeginLoc(), diag::warn_frame_address) << ((BuiltinID == Builtin::BI__builtin_return_address) Index: clang/test/Sema/builtin-returnaddress.c === --- clang/test/Sema/builtin-returnaddress.c +++ clang/test/Sema/builtin-returnaddress.c @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s // RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s +// RUN: %clang_cc1 -x c++ -fsyntax-only -Wframe-address -verify %s +// RUN: %clang_cc1 -x c++ -fsyntax-only -Wmost -verify %s void* a(unsigned x) { return __builtin_return_address(0); @@ -17,3 +19,14 @@ return __builtin_frame_address(1); // expected-warning{{calling '__builtin_frame_address' with a nonzero argument is unsafe}} } +#ifdef __cplusplus +template void *RA() +{ + return __builtin_return_address(N); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}} +} + +void *foo() +{ + return RA<2>(); // expected-note{{in instantiation of function template specialization 'RA<2>' requested here}} +} +#endif Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -1942,7 +1942,8 @@ // -Wframe-address warning if non-zero passed to builtin // return/frame address. Expr::EvalResult Result; -if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) && +if (!TheCall->getArg(0)->isValueDependent() && +TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) && Result.Val.getInt() != 0) Diag(TheCall->getBeginLoc(), diag::warn_frame_address) << ((BuiltinID == Builtin::BI__builtin_return_address) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D94438: Fis for Assertion failure on dependent expression.
Sunil_Srivastava marked an inline comment as done. Sunil_Srivastava added inline comments. Comment at: clang/test/Sema/builtin-returnaddress.c:3 // RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s +// RUN: %clang_cc1 -x c++ -fsyntax-only -Wframe-address -verify %s +// RUN: %clang_cc1 -x c++ -fsyntax-only -Wmost -verify %s erichkeane wrote: > I don't think the -Wmost test 'RUN' line is valuable for the C++ mode, it is > simply validating that this diagnostic is in Wmost mode (which running in C > mode is sufficient). Good point. I will remove that. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D94438/new/ https://reviews.llvm.org/D94438 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D94438: Fis for Assertion failure on dependent expression.
This revision was automatically updated to reflect the committed changes. Sunil_Srivastava marked an inline comment as done. Closed by commit rGf706486eaf07: Fix for crash in __builtin_return_address in template context. (authored by Sunil_Srivastava). Changed prior to commit: https://reviews.llvm.org/D94438?vs=315873&id=316201#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D94438/new/ https://reviews.llvm.org/D94438 Files: clang/lib/Sema/SemaChecking.cpp clang/test/Sema/builtin-returnaddress.c Index: clang/test/Sema/builtin-returnaddress.c === --- clang/test/Sema/builtin-returnaddress.c +++ clang/test/Sema/builtin-returnaddress.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s // RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s +// RUN: %clang_cc1 -x c++ -fsyntax-only -Wframe-address -verify %s void* a(unsigned x) { return __builtin_return_address(0); @@ -17,3 +18,14 @@ return __builtin_frame_address(1); // expected-warning{{calling '__builtin_frame_address' with a nonzero argument is unsafe}} } +#ifdef __cplusplus +template void *RA() +{ + return __builtin_return_address(N); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}} +} + +void *foo() +{ + return RA<2>(); // expected-note{{in instantiation of function template specialization 'RA<2>' requested here}} +} +#endif Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -1943,7 +1943,8 @@ // -Wframe-address warning if non-zero passed to builtin // return/frame address. Expr::EvalResult Result; -if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) && +if (!TheCall->getArg(0)->isValueDependent() && +TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) && Result.Val.getInt() != 0) Diag(TheCall->getBeginLoc(), diag::warn_frame_address) << ((BuiltinID == Builtin::BI__builtin_return_address) Index: clang/test/Sema/builtin-returnaddress.c === --- clang/test/Sema/builtin-returnaddress.c +++ clang/test/Sema/builtin-returnaddress.c @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -Wframe-address -verify %s // RUN: %clang_cc1 -fsyntax-only -Wmost -verify %s +// RUN: %clang_cc1 -x c++ -fsyntax-only -Wframe-address -verify %s void* a(unsigned x) { return __builtin_return_address(0); @@ -17,3 +18,14 @@ return __builtin_frame_address(1); // expected-warning{{calling '__builtin_frame_address' with a nonzero argument is unsafe}} } +#ifdef __cplusplus +template void *RA() +{ + return __builtin_return_address(N); // expected-warning{{calling '__builtin_return_address' with a nonzero argument is unsafe}} +} + +void *foo() +{ + return RA<2>(); // expected-note{{in instantiation of function template specialization 'RA<2>' requested here}} +} +#endif Index: clang/lib/Sema/SemaChecking.cpp === --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -1943,7 +1943,8 @@ // -Wframe-address warning if non-zero passed to builtin // return/frame address. Expr::EvalResult Result; -if (TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) && +if (!TheCall->getArg(0)->isValueDependent() && +TheCall->getArg(0)->EvaluateAsInt(Result, getASTContext()) && Result.Val.getInt() != 0) Diag(TheCall->getBeginLoc(), diag::warn_frame_address) << ((BuiltinID == Builtin::BI__builtin_return_address) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits